aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mumd/src/network.rs6
-rw-r--r--mumd/src/state.rs11
2 files changed, 15 insertions, 2 deletions
diff --git a/mumd/src/network.rs b/mumd/src/network.rs
index a90a0fc..947612f 100644
--- a/mumd/src/network.rs
+++ b/mumd/src/network.rs
@@ -135,7 +135,7 @@ async fn listen_tcp(
ControlPacket::ServerSync(msg) => {
info!("Logged in");
if let Some(sender) = crypt_state_sender.take() {
- sender.send(
+ let _ = sender.send(
crypt_state
.take()
.expect("Server didn't send us any CryptSetup packet!"),
@@ -173,7 +173,9 @@ async fn listen_tcp(
debug!("Channel state received");
server.lock().unwrap().parse_channel_state(msg);
}
- ControlPacket::ChannelRemove(msg) => {}
+ ControlPacket::ChannelRemove(msg) => {
+ server.lock().unwrap().parse_channel_remove(msg);
+ }
_ => {}
}
}
diff --git a/mumd/src/state.rs b/mumd/src/state.rs
index 6e0d908..1ef8467 100644
--- a/mumd/src/state.rs
+++ b/mumd/src/state.rs
@@ -35,6 +35,17 @@ impl Server {
}
}
+ pub fn parse_channel_remove(&mut self, msg: Box<msgs::ChannelRemove>) {
+ if !msg.has_channel_id() {
+ warn!("Can't parse channel remove without channel id");
+ return;
+ }
+ match self.channels.entry(msg.get_channel_id()) {
+ Entry::Vacant(_) => { warn!("Attempted to remove channel that doesn't exist"); }
+ Entry::Occupied(e) => { e.remove(); }
+ }
+ }
+
pub fn parse_user_state(&mut self, msg: Box<msgs::UserState>) {
if !msg.has_session() {
warn!("Can't parse user state without session");