From c46a5427d8131d877965861d81dceffd53ec8e9c Mon Sep 17 00:00:00 2001 From: The DT Date: Mon, 18 Dec 2023 22:37:37 +0700 Subject: [PATCH] update --- src/main.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 43b75cb..0275728 100644 --- a/src/main.rs +++ b/src/main.rs @@ -193,8 +193,7 @@ struct InnerReceiver { #[derive(Clone)] struct CallbackR { - ws: UnboundedSender, - pub accumulator: DashMap + ws: UnboundedSender } @@ -203,8 +202,7 @@ impl CallbackR { // You can manage state here, such as a buffer of audio packet bytes so // you can later store them in intervals. Self { - ws, - accumulator: DashMap::default() + ws } } } @@ -238,7 +236,6 @@ impl EventHandler for CallbackR { Ctx::VoiceTick(packet) => { for i in &packet.speaking { let data_out = &i.1.decoded_voice; - let old_data: Option> = self.accumulator.get_mut(i.0); if data_out.is_some() { let data = data_out.as_ref().unwrap(); let mut data_u8 = Vec::new(); @@ -255,6 +252,12 @@ impl EventHandler for CallbackR { } } }, + Ctx::DriverConnect(data) => { + let jdata = json!({ + "t": "CONNECTED" + }); + let _ = self.ws.send(Message::Text(jdata.to_string())); + }, _ => { // We won't be registering this struct for any more event classes. unimplemented!() @@ -290,10 +293,11 @@ async fn accept_connection(ws_stream: WebSocket) { }); let mut controler: Option = None; let evt_receiver = CallbackR::new(send_s.clone()); - dr.add_global_event(Event::Track(songbird::TrackEvent::End), Callback {ws: send_s.clone(), data: jdata.clone(), data_err: jdata_err.clone()}); dr.add_global_event(CoreEvent::SpeakingStateUpdate.into(), evt_receiver.clone()); dr.add_global_event(CoreEvent::VoiceTick.into(), evt_receiver.clone()); + dr.add_global_event(CoreEvent::ClientDisconnect.into(), evt_receiver.clone()); + dr.add_global_event(CoreEvent::DriverConnect.into(), evt_receiver.clone()); let mut volume = 100; while let Some(msg) = read.next().await { if msg.is_err() {