Where the shared stream is in its lifecycle. 'connecting' spans from socket creation until the primary reports the bound JID (_bound) or a worker-driven resumption succeeds; only in 'established' are join requests answered — earlier ones wait in _pendingJoins.
The worker-resident XEP-0198 engine (created lazily on the first SM negotiation). The worker is the only party that sees all inbound traffic (one socket) and all outbound traffic (every port's send relays through here), so it is the only correct owner of the SM counters and queue once more than one tab sends — a stanza sent from a secondary tab survives resumption, and failover needs no reconnect.
Attach to the shared session, if there is one.
Optional_service: stringOptionalversion: number
The page's SHARED_WORKER_PROTOCOL_VERSION.
The primary reports that the connect flow completed (resource bound,
or legacy auth/session establishment finished): adopt the bound JID as
the shared one so attaching secondaries and promotions hand out a
resource the server actually knows about, start a fresh SM session if
this stream's features advertised support (_smFeatures), and release
any joins parked on the handshake. The
The server-assigned full JID.
Graceful removal (sent from pagehide). If the primary leaves, the next live port is promoted on the same socket.
Explicitly close the shared socket (a deliberate disconnect/logout —
a mere tab close sends _bye instead). Joins parked on the handshake
are answered with ATTACHFAIL: the session they were waiting for is
not going to happen.
Optional_port: MessagePortConnect, or (when a live socket for the same user already exists) join the shared session as a secondary instead of reconnecting (§2.5). The first joiner becomes primary and drives the connection.
Optionalversion: numberDeliver an inbound frame to the tabs, feeding it to the XEP-0198
engine first: counting and
Until the session is established, frames go only to the primary, since only it is responsible for SASL negotiation and session setup. Once established, frames are broadcast to all tabs.
Liveness reply to the worker's _ping. The lastSeen update happens in the dispatcher, so any message from a port counts. This method only needs to exist.
The page announces it is about to be frozen (its CPU stops): hand the primary role to the freshest other port right away instead of making the worker discover the freeze through missed pongs.
The primary reports that the post-SASL stream features advertise
XEP-0198 (§2.3). This is the resume-vs-bind decision point: only the
worker knows whether resumable state exists, so it either sends
Register a newly connected port. It is admitted (and given a role) when it first speaks.
Send the stream-closing frame before disconnecting.
Relay an outbound frame to the socket, feeding it to the XEP-0198 engine and reflecting messages/presences to the other tabs.
Manages the shared websocket connection as well as the ports of the connected tabs.