rust/hedgewars-server/src/handlers/inlobby.rs
changeset 15075 e935b1ad23f3
parent 15074 c5a6e8566425
child 15439 a158ff8f84ef
equal deleted inserted replaced
15074:c5a6e8566425 15075:e935b1ad23f3
     1 use mio;
     1 use mio;
     2 
     2 
     3 use super::common::rnd_reply;
     3 use super::common::rnd_reply;
     4 use crate::{
     4 use crate::{
       
     5     core::{
       
     6         client::HwClient,
       
     7         server::HwServer,
       
     8         types::{ClientId, ServerVar},
       
     9     },
     5     protocol::messages::{
    10     protocol::messages::{
     6         add_flags, remove_flags, server_chat, HWProtocolMessage, HWServerMessage::*,
    11         add_flags, remove_flags, server_chat, HwProtocolMessage, HwServerMessage::*,
     7         ProtocolFlags as Flags,
    12         ProtocolFlags as Flags,
     8     },
       
     9     core::{
       
    10         client::HWClient,
       
    11         server::HWServer,
       
    12         types::{ClientId, ServerVar},
       
    13     },
    13     },
    14     utils::is_name_illegal,
    14     utils::is_name_illegal,
    15 };
    15 };
    16 use log::*;
    16 use log::*;
    17 use std::{collections::HashSet, convert::identity};
    17 use std::{collections::HashSet, convert::identity};
    18 
    18 
    19 pub fn handle(
    19 pub fn handle(
    20     server: &mut HWServer,
    20     server: &mut HwServer,
    21     client_id: ClientId,
    21     client_id: ClientId,
    22     response: &mut super::Response,
    22     response: &mut super::Response,
    23     message: HWProtocolMessage,
    23     message: HwProtocolMessage,
    24 ) {
    24 ) {
    25     use crate::protocol::messages::HWProtocolMessage::*;
    25     use crate::protocol::messages::HwProtocolMessage::*;
    26     match message {
    26     match message {
    27         CreateRoom(name, password) => {
    27         CreateRoom(name, password) => {
    28             if is_name_illegal(&name) {
    28             if is_name_illegal(&name) {
    29                 response.add(Warning("Illegal room name! A room name must be between 1-40 characters long, must not have a trailing or leading space and must not have any of these characters: $()*+?[]^{|}".to_string()).send_self());
    29                 response.add(Warning("Illegal room name! A room name must be between 1-40 characters long, must not have a trailing or leading space and must not have any of these characters: $()*+?[]^{|}".to_string()).send_self());
    30             } else if server.has_room(&name) {
    30             } else if server.has_room(&name) {
    92             } else {
    92             } else {
    93                 response.add(Warning("No such room.".to_string()).send_self());
    93                 response.add(Warning("No such room.".to_string()).send_self());
    94             }
    94             }
    95         }
    95         }
    96         Follow(nick) => {
    96         Follow(nick) => {
    97             if let Some(HWClient {
    97             if let Some(HwClient {
    98                 room_id: Some(room_id),
    98                 room_id: Some(room_id),
    99                 ..
    99                 ..
   100             }) = server.find_client(&nick)
   100             }) = server.find_client(&nick)
   101             {
   101             {
   102                 let room = &server.rooms[*room_id];
   102                 let room = &server.rooms[*room_id];