aboutsummaryrefslogtreecommitdiffstats
path: root/mumd
diff options
context:
space:
mode:
Diffstat (limited to 'mumd')
-rw-r--r--mumd/src/network/tcp.rs5
-rw-r--r--mumd/src/state.rs15
2 files changed, 8 insertions, 12 deletions
diff --git a/mumd/src/network/tcp.rs b/mumd/src/network/tcp.rs
index 0432be1..630f46a 100644
--- a/mumd/src/network/tcp.rs
+++ b/mumd/src/network/tcp.rs
@@ -16,7 +16,6 @@ use tokio::time::{self, Duration};
use tokio_tls::{TlsConnector, TlsStream};
use tokio_util::codec::{Decoder, Framed};
use std::collections::HashMap;
-use std::collections::hash_map::Entry;
use std::future::Future;
use std::rc::Rc;
use std::cell::RefCell;
@@ -251,16 +250,12 @@ async fn listen(
}
ControlPacket::UserState(msg) => {
let mut state = state.lock().unwrap();
- let session = msg.get_session();
if *state.phase_receiver().borrow() == StatePhase::Connecting {
state.audio_mut().add_client(msg.get_session());
state.parse_user_state(*msg);
} else {
state.parse_user_state(*msg);
}
- let server = state.server_mut().unwrap();
- let user = server.users().get(&session).unwrap();
- info!("User {} connected to {}", user.name(), user.channel());
}
ControlPacket::UserRemove(msg) => {
state.lock().unwrap().remove_client(*msg);
diff --git a/mumd/src/state.rs b/mumd/src/state.rs
index b27d401..3aff353 100644
--- a/mumd/src/state.rs
+++ b/mumd/src/state.rs
@@ -214,9 +214,9 @@ impl State {
// check if this is initial state
if !self.server().unwrap().users().contains_key(&session) {
self.parse_initial_user_state(session, msg);
- None
+ return None;
} else {
- Some(self.parse_updated_user_state(session, msg))
+ return Some(self.parse_updated_user_state(session, msg));
}
}
@@ -256,14 +256,15 @@ impl State {
user.apply_user_diff(&diff);
let user = self.server().unwrap().users().get(&session).unwrap();
- // send notification
+ // send notification if the user moved to or from any channel
+ //TODO our channel only
if let Some(channel_id) = diff.channel_id {
if let Some(channel) = self.server().unwrap().channels().get(&channel_id) {
libnotify::Notification::new("mumd",
- Some(format!("{} moved to channel {}",
- &user.name(),
- channel.name()).as_str()),
- None)
+ Some(format!("{} moved to channel {}",
+ &user.name(),
+ channel.name()).as_str()),
+ None)
.show().unwrap();
} else {
warn!("{} moved to invalid channel {}", &user.name(), channel_id);