Speaking indicator
This commit is contained in:
+11
-4
@@ -55,11 +55,19 @@ impl Server {
|
|||||||
};
|
};
|
||||||
drop(clients);
|
drop(clients);
|
||||||
|
|
||||||
*user.voice.lock().await = Some(crate::server::VoiceConnection {
|
let mut voice = user.voice.lock().await;
|
||||||
|
|
||||||
|
if let Some(voice) = &mut *voice {
|
||||||
|
voice.addr = addr;
|
||||||
|
} else {
|
||||||
|
*voice = Some(crate::server::VoiceConnection {
|
||||||
addr,
|
addr,
|
||||||
channel_id: channel_id.clone(),
|
channel_id: channel_id.clone(),
|
||||||
last_speaking_sent: Instant::now(),
|
last_speaking_sent: Instant::now(),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
drop(voice);
|
||||||
|
|
||||||
self.relay_voice(&sender_pubkey, &channel_id, payload)
|
self.relay_voice(&sender_pubkey, &channel_id, payload)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -104,11 +112,10 @@ impl Server {
|
|||||||
|
|
||||||
if now.duration_since(voice.last_speaking_sent).as_millis() >= 600 {
|
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 _ = conn
|
conn.send(&ClientMethod::Speaking {
|
||||||
.send(&ClientMethod::Speaking {
|
|
||||||
pubkey: crate::crypto::to_string(sender),
|
pubkey: crate::crypto::to_string(sender),
|
||||||
})
|
})
|
||||||
.await;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
voice.last_speaking_sent = now;
|
voice.last_speaking_sent = now;
|
||||||
|
|||||||
Reference in New Issue
Block a user