feat(signal): PresenceList broadcast for lobby user discovery
New signal infrastructure for the lobby-first UI:
- PresenceUser struct: { fingerprint, alias }
- SignalMessage::PresenceList: relay broadcasts full user list
to all signal clients on every register/deregister
- SignalHub::presence_list(): builds the list from connected clients
- SignalHub::broadcast(): sends to ALL signal clients
- Relay calls broadcast on register + unregister
- Desktop emits "presence_list" signal-event to JS frontend
This gives clients real-time visibility of who's online via the
signal channel, without needing to join a voice room first.
603 tests pass, 0 regressions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,26 @@ impl SignalHub {
|
||||
pub fn alias(&self, fp: &str) -> Option<&str> {
|
||||
self.clients.get(fp).and_then(|c| c.alias.as_deref())
|
||||
}
|
||||
|
||||
/// Build a PresenceList message with all online users.
|
||||
pub fn presence_list(&self) -> SignalMessage {
|
||||
let users: Vec<wzp_proto::PresenceUser> = self
|
||||
.clients
|
||||
.values()
|
||||
.map(|c| wzp_proto::PresenceUser {
|
||||
fingerprint: c.fingerprint.clone(),
|
||||
alias: c.alias.clone(),
|
||||
})
|
||||
.collect();
|
||||
SignalMessage::PresenceList { users }
|
||||
}
|
||||
|
||||
/// Broadcast a message to ALL connected signal clients.
|
||||
pub async fn broadcast(&self, msg: &SignalMessage) {
|
||||
for client in self.clients.values() {
|
||||
let _ = client.transport.send_signal(msg).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user