aboutsummaryrefslogtreecommitdiffstats
path: root/mumd
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-06-07 00:50:15 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-06-07 00:50:15 +0200
commit2b63fa8ac1b7e7d995955758f8cd9ab2ec7d4e0e (patch)
tree9c7bb675eb590aac535746ca1058ea873d4fea5a /mumd
parent0cc89730e82464e8f6c4ee69a4791fdd0135178c (diff)
downloadmum-2b63fa8ac1b7e7d995955758f8cd9ab2ec7d4e0e.tar.gz
events command
Diffstat (limited to 'mumd')
-rw-r--r--mumd/src/state.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/mumd/src/state.rs b/mumd/src/state.rs
index f831258..c51c139 100644
--- a/mumd/src/state.rs
+++ b/mumd/src/state.rs
@@ -15,7 +15,7 @@ use mumble_protocol::control::msgs;
use mumble_protocol::control::ControlPacket;
use mumble_protocol::ping::PongPacket;
use mumble_protocol::voice::Serverbound;
-use mumlib::command::{Command, CommandResponse, MessageTarget};
+use mumlib::command::{Command, CommandResponse, Event, MessageTarget};
use mumlib::config::Config;
use mumlib::Error;
use std::{
@@ -60,11 +60,6 @@ pub enum ExecutionContext {
),
}
-pub enum Event {
- UserConnected(String, Option<String>),
- UserDisconnected(String, Option<String>),
-}
-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum StatePhase {
Disconnected,
@@ -435,6 +430,19 @@ pub fn handle_command(
new_deaf.map(|b| CommandResponse::DeafenStatus { is_deafened: b })
))
}
+ Command::Events { block } => {
+ if block {
+ warn!("Blocking event list is unimplemented");
+ now!(Ok(None))
+ } else {
+ let events: Vec<_> = state
+ .events
+ .iter()
+ .map(|event| Ok(Some(CommandResponse::Event { event: event.clone() })))
+ .collect();
+ ExecutionContext::Now(Box::new(move || Box::new(events.into_iter())))
+ }
+ }
Command::InputVolumeSet(volume) => {
state.audio_input.set_volume(volume);
now!(Ok(None))
@@ -618,12 +626,12 @@ pub fn handle_command(
}),
Box::new(move |pong| {
Ok(pong.map(|pong| {
- (CommandResponse::ServerStatus {
+ CommandResponse::ServerStatus {
version: pong.version,
users: pong.users,
max_users: pong.max_users,
bandwidth: pong.bandwidth,
- })
+ }
}))
}),
),