Current connection lifecycle state.
Which concrete transport is active.
Establish a connection to (or create) the specified room.
Room credentials and mode selection.
Resolves when the connection is ready to send and receive events.
Tear down the connection and release all resources.
Subscribe to incoming events.
Called for every event received.
An unsubscribe function — call it to stop receiving events.
Send an event to the other side of the connection.
Any TransportEvent variant.
Relay-server transport implemented via Gun.js with SEA encryption.
Remarks
Gun.js is a decentralised, eventually-consistent graph database that uses public relay servers as a signalling and message-relay layer. Unlike PeerJS, it does not require a direct WebRTC connection between peers — all data flows through the relay, making it more reliable behind restrictive NATs and corporate firewalls.
Encryption: Every event is symmetrically encrypted with SEA (Security, Encryption, Authorization) using a shared secret derived from
passphrase+roomIdviaSEA.work(). This prevents relay server operators or other Gun.js users from reading game data. The passphrase is displayed to players as part of the QR code payload.Namespace: Events are written to the Gun graph under the key
viktorani:<roomId>/events/<timestamp-random>. Each event gets a unique key so Gun's CRDT merge does not overwrite previous entries.Fallback role: In
'auto'mode, transport.TransportManager instantiates this class only when transport/PeerJSTransport.PeerJSTransport fails — typically when the PeerJS cloud server is unreachable.