Skip to main content

Module websocket

Module websocket 

Source
Expand description

MessageBox WebSocket layer over the shared authsocket client.

The generic BRC-103/Socket.IO transport (connect + namespace-ack gate, client-initiated handshake, authenticationSuccess oneshot, receive loop, keepalive + read-deadline watchdog, signed emit/join_room/leave_room) lives in the authsocket crate’s client feature — it was extracted from this file. What remains here is the MessageBox application protocol:

  • sendMessage-{roomId} room deliveries: decode ServerPeerMessage, decrypt (BRC-78) with authenticated-decrypt provenance, and dispatch to the room subscription callback.
  • sendMessageAck-{roomId} FIFO ack correlation: the server’s ack is room-scoped (no messageId), so N concurrent sends to one room resolve oldest-first against a per-key VecDeque of waiters.
  • the public MessageBoxWebSocket API surface, unchanged for client.rs and delivery.rs.

Inbound routing preserves the old dispatcher’s strict FIFO semantics: the authsocket fallback handler forwards (event_name, data) onto an internal channel consumed by one dispatcher task, so per-room message/ack ordering is exactly as the server emitted it.

Structs§

MessageBoxWebSocket
WebSocket connection to the MessageBox server: the shared authsocket BRC-103 client plus the MessageBox application routing.