From d55988bb83caffafc1505ea5095543352d35d38b Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:20:02 +0100 Subject: [PATCH] feat: add VoiceData reference to UdpHandler --- src/voice/udp.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/voice/udp.rs b/src/voice/udp.rs index 7830613..d384b0d 100644 --- a/src/voice/udp.rs +++ b/src/voice/udp.rs @@ -3,7 +3,7 @@ use std::{net::SocketAddr, sync::Arc}; use log::{info, warn}; -use tokio::net::UdpSocket; +use tokio::{net::UdpSocket, sync::Mutex}; use discortp::{ demux::{demux, Demuxed}, @@ -11,6 +11,8 @@ use discortp::{ Packet, }; +use super::voice_data::VoiceData; + /// Handle to a voice udp connection /// /// Can be safely cloned and will still correspond to the same connection. @@ -23,11 +25,16 @@ pub struct UdpHandle { #[derive(Debug)] pub struct UdpHandler { + data: Arc>, socket: Arc, } impl UdpHandler { - pub async fn spawn(url: SocketAddr, ssrc: u32) -> UdpHandle { + pub async fn spawn( + data_reference: Arc>, + url: SocketAddr, + ssrc: u32, + ) -> UdpHandle { // Bind with a port number of 0, so the os assigns this listener a port let udp_socket = UdpSocket::bind("0.0.0.0:0").await.unwrap(); @@ -84,6 +91,7 @@ impl UdpHandler { let socket = Arc::new(udp_socket); let mut handler = UdpHandler { + data: data_reference, socket: socket.clone(), };