This commit is contained in:
+9
-9
@@ -81,15 +81,15 @@ async fn handle_voice_socket(
|
||||
select! {
|
||||
// Receive audio from other users and send to client
|
||||
voice_packet = rx.recv() => {
|
||||
if let Ok((speaker_uuid, audio_data)) = voice_packet {
|
||||
if speaker_uuid != my_uuid {
|
||||
let mut msg = BytesMut::with_capacity(16 + audio_data.len());
|
||||
msg.put(speaker_uuid.as_bytes().as_slice());
|
||||
msg.put(audio_data);
|
||||
if let Ok((speaker_uuid, audio_data)) = voice_packet
|
||||
&& speaker_uuid != my_uuid
|
||||
{
|
||||
let mut msg = BytesMut::with_capacity(16 + audio_data.len());
|
||||
msg.put(speaker_uuid.as_bytes().as_slice());
|
||||
msg.put(audio_data);
|
||||
|
||||
if socket.send(Message::Binary(msg.freeze().into())).await.is_err() {
|
||||
break;
|
||||
}
|
||||
if socket.send(Message::Binary(msg.freeze())).await.is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ async fn handle_voice_socket(
|
||||
if let Some(Ok(msg)) = client_msg {
|
||||
match msg {
|
||||
Message::Binary(data) => {
|
||||
let _ = tx.send((my_uuid, Bytes::from(data)));
|
||||
let _ = tx.send((my_uuid, data));
|
||||
}
|
||||
Message::Close(_) => {
|
||||
tracing::debug!("Voice client {} disconnected", who);
|
||||
|
||||
Reference in New Issue
Block a user