33 .with_protocol(room.protocol_number), |
33 .with_protocol(room.protocol_number), |
34 ); |
34 ); |
35 response.add(RoomJoined(vec![client.nick.clone()]).send_self()); |
35 response.add(RoomJoined(vec![client.nick.clone()]).send_self()); |
36 response.add( |
36 response.add( |
37 ClientFlags( |
37 ClientFlags( |
38 add_flags(&[Flags::RoomMaster, Flags::Ready]), |
38 add_flags(&[Flags::RoomMaster, Flags::Ready, Flags::InRoom]), |
39 vec![client.nick.clone()], |
39 vec![client.nick.clone()], |
40 ) |
40 ) |
41 .send_self(), |
41 .send_all(), |
42 ); |
|
43 response.add( |
|
44 ClientFlags(add_flags(&[Flags::InRoom]), vec![client.nick.clone()]).send_self(), |
|
45 ); |
42 ); |
46 } |
43 } |
47 }, |
44 }, |
48 Chat(msg) => { |
45 Chat(msg) => { |
49 response.add( |
46 response.add( |
50 ChatMsg { |
47 ChatMsg { |
51 nick: server.get_client_nick(client_id).to_string(), |
48 nick: server.client(client_id).nick.clone(), |
52 msg, |
49 msg, |
53 } |
50 } |
54 .send_all() |
51 .send_all() |
55 .in_lobby() |
52 .in_lobby() |
56 .but_self(), |
53 .but_self(), |
57 ); |
54 ); |
58 } |
55 } |
59 JoinRoom(name, _password) => match server.join_room_by_name(client_id, &name) { |
56 JoinRoom(name, password) => { |
60 Err(error) => super::common::get_room_join_error(error, response), |
57 match server.join_room_by_name(client_id, &name, password.as_deref()) { |
61 Ok((client, room, room_clients)) => { |
58 Err(error) => super::common::get_room_join_error(error, response), |
62 super::common::get_room_join_data(client, room, room_clients, response) |
59 Ok((client, room, room_clients)) => { |
|
60 super::common::get_room_join_data(client, room, room_clients, response) |
|
61 } |
63 } |
62 } |
64 }, |
63 } |
65 Follow(nick) => { |
64 Follow(nick) => { |
66 if let Some(client) = server.find_client(&nick) { |
65 if let Some(client) = server.find_client(&nick) { |
67 if let Some(room_id) = client.room_id { |
66 if let Some(room_id) = client.room_id { |
68 match server.join_room(client_id, room_id) { |
67 match server.join_room(client_id, room_id, None) { |
69 Err(error) => super::common::get_room_join_error(error, response), |
68 Err(error) => super::common::get_room_join_error(error, response), |
70 Ok((client, room, room_clients)) => { |
69 Ok((client, room, room_clients)) => { |
71 super::common::get_room_join_data(client, room, room_clients, response) |
70 super::common::get_room_join_data(client, room, room_clients, response) |
72 } |
71 } |
73 } |
72 } |