From 2b63fa8ac1b7e7d995955758f8cd9ab2ec7d4e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 7 Jun 2021 00:50:15 +0200 Subject: events command --- mumd/src/state.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'mumd/src') 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), - UserDisconnected(String, Option), -} - #[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, - }) + } })) }), ), -- cgit v1.2.1