This commit is contained in:
2026-08-27 02:22:56 +02:00
parent 8887c96f05
commit 02a444d6ed
2 changed files with 31 additions and 14 deletions
+28 -11
View File
@@ -49,6 +49,11 @@ pub enum ClientMethod {
pin: u64, pin: u64,
}, },
UserJoinedVoice {
channel_id: String,
pubkey: String,
},
Speaking { Speaking {
pubkey: String, pubkey: String,
}, },
@@ -167,19 +172,31 @@ pub async fn read_loop(
} }
ServerMethod::JoinVoice { channel_id } => { ServerMethod::JoinVoice { channel_id } => {
let pin = rand::random::<u64>() % (1 << 53); {
let pin = rand::random::<u64>() % (1 << 53);
server
.voice_pins
.lock()
.await
.insert(pin, (verifying_key, channel_id.clone()));
send_socket(
&mut *socket.lock().await,
&ClientMethod::JoinVoice {
channel_id: channel_id.clone(),
pin,
},
)
.await?;
}
server server
.voice_pins .broadcast(&ClientMethod::UserJoinedVoice {
.lock() channel_id,
.await pubkey: crate::crypto::to_string(&verifying_key),
.insert(pin, (verifying_key, channel_id.clone())); })
.await?;
send_socket(
&mut *socket.lock().await,
&ClientMethod::JoinVoice { channel_id, pin },
)
.await?;
} }
} }
+3 -3
View File
@@ -105,7 +105,7 @@ impl Server {
let now = Instant::now(); let now = Instant::now();
if now.duration_since(voice.last_speaking_sent).as_millis() >= 1000 { if now.duration_since(voice.last_speaking_sent).as_millis() >= 600 {
for conn in user.connections.lock().await.values() { for conn in user.connections.lock().await.values() {
let _ = send_socket( let _ = send_socket(
&mut *conn.lock().await, &mut *conn.lock().await,
@@ -115,9 +115,9 @@ impl Server {
) )
.await; .await;
} }
}
voice.last_speaking_sent = now; voice.last_speaking_sent = now;
}
let _ = self.udp_send_to(&voice.addr, payload).await; let _ = self.udp_send_to(&voice.addr, payload).await;
} }