From 83e144ef7ce0e922be14cd2ef2abc938ab971c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 23 Oct 2020 02:40:07 +0200 Subject: send notif when someone disconnects --- mumd/src/state.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mumd/src/state.rs') diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 39221a3..85245a6 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -222,6 +222,7 @@ impl State { // this is someone else self.audio_mut().add_client(sess); + // send notification only if we've passed the connecting phase if *self.phase_receiver().borrow() == StatePhase::Connected { let channel_id = if msg.has_channel_id() { msg.get_channel_id() @@ -269,6 +270,14 @@ impl State { warn!("Tried to remove user state without session"); return; } + if let Some(user) = self.server().unwrap().users().get(&msg.get_session()) { + libnotify::Notification::new("mumd", + Some(format!("{} disconnected", + &user.name()).as_str()), + None) + .show().unwrap(); + } + self.audio().remove_client(msg.get_session()); self.server_mut().unwrap().users_mut().remove(&msg.get_session()); info!("User {} disconnected", msg.get_session()); -- cgit v1.2.1