diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-10-18 02:30:39 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-10-21 01:07:43 +0200 |
| commit | d9a3470fcb4c8c63dd5fb76dd7f2f7eb977d8b0d (patch) | |
| tree | 5083c6f0e270818eb40b5cd822472ac9218e041e /mumd/src | |
| parent | 9f4c05059f1990a23995e3363f88ab753187042d (diff) | |
| download | mum-d9a3470fcb4c8c63dd5fb76dd7f2f7eb977d8b0d.tar.gz | |
implement remove_client
Diffstat (limited to 'mumd/src')
| -rw-r--r-- | mumd/src/network/tcp.rs | 3 | ||||
| -rw-r--r-- | mumd/src/state.rs | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/mumd/src/network/tcp.rs b/mumd/src/network/tcp.rs index c4804f8..6471771 100644 --- a/mumd/src/network/tcp.rs +++ b/mumd/src/network/tcp.rs @@ -295,8 +295,7 @@ async fn listen( info!("User {} connected to {}", user.name(), user.channel()); } ControlPacket::UserRemove(msg) => { - info!("User {} left", msg.get_session()); - state.lock().unwrap().remove_client(msg.get_session()); + state.lock().unwrap().remove_client(*msg); } ControlPacket::ChannelState(msg) => { debug!("Channel state received"); diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 494f61f..8dc3d68 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -204,8 +204,14 @@ impl State { } } - pub fn remove_client(&mut self, session: u32) { - + pub fn remove_client(&mut self, msg: msgs::UserRemove) { + if !msg.has_session() { + warn!("Tried to remove user state without session"); + return; + } + self.audio().remove_client(msg.get_session()); + self.server_mut().unwrap().users_mut().remove(&msg.get_session()); + info!("User {} disconnected", msg.get_session()); } pub fn reload_config(&mut self) { |
