Hybrid peer manager¶
HybridPeerManager starts with a WebSocket connection and can upgrade each
peer connection to a WebRTC DataChannel. WebSocket signaling carries the SDP
offer/answer and ICE candidates. A lexicographic peer-ID tie-breaker chooses
which side creates the offer, avoiding glare.
Sending prefers an open WebRTC DataChannel and falls back to the WebSocket relay. Broadcasts use WebRTC for connected peers and relay only for peers without a live channel. If WebRTC setup fails, the manager retries with TURN once and then emits a downgrade while continuing over WebSocket.
This is still relay-assisted peer sync: WebRTC changes the transport path, not the CRDT ownership model. The relay remains involved for initial connection, signaling, and fallback traffic.