Strophe.js
    Preparing search index...

    Manages the shared websocket connection as well as the ports of the connected tabs.

    Index
    jid: string
    ports: Map<MessagePort, PortInfo>
    service: string
    session: "none" | "connecting" | "established"

    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.

    socket: WebSocket
    • Attach to the shared session, if there is one.

      Parameters

      • port: MessagePort
      • Optional_service: string
      • Optionalversion: number

        The page's SHARED_WORKER_PROTOCOL_VERSION.

      Returns void

    • 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 is written before the parked joins drain, so it precedes anything a newly attached tab sends.

      Parameters

      • _port: MessagePort
      • jid: string

        The server-assigned full JID.

      Returns void

    • Graceful removal (sent from pagehide). If the primary leaves, the next live port is promoted on the same socket.

      Parameters

      • port: MessagePort

      Returns void

    • 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.

      Parameters

      • Optional_port: MessagePort

      Returns void

    • Connect, 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.

      Parameters

      • port: MessagePort
      • service: string
      • jid: string
      • Optionalversion: number

      Returns void

    • 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.

      Parameters

      • _port: MessagePort

      Returns void

    • 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.

      Parameters

      • port: MessagePort

      Returns void

    • 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 itself (answering with _smResumed/_smFailed once the server replies) or tells the requesting port to proceed with binding.

      Parameters

      • port: MessagePort

      Returns void

    • Register a newly connected port. It is admitted (and given a role) when it first speaks.

      Parameters

      • port: MessagePort

      Returns void

    • Send the stream-closing frame before disconnecting.

      Parameters

      • port: MessagePort
      • data: string

      Returns void

    • Relay an outbound frame to the socket, feeding it to the XEP-0198 engine and reflecting messages/presences to the other tabs.

      Parameters

      • port: MessagePort
      • data: string

      Returns void