The Connection that owns this transport.
The wrapper element name whose children Connection unwraps before
dispatch. BOSH overloads it as a boolean toggle, hence the union.
Private helper that makes sure all pending requests are aborted. A component has no in-flight requests, so this is a no-op.
Private checks a received stream error and tears the connection down.
The stream:error/ element.
Private function to close the TCP socket and drop its listeners.
Private function called by Connection.connect
Opens a TCP socket to the component listener and wires up its callbacks.
Private function called by Connection._connect_cb
The component protocol has no stream:features to inspect, so there is nothing to check here. Kept for interface parity with the other transports.
Private function called by Connection.disconnect Sends an optional last stanza, then the closing stream tag, then tears down the socket.
Optionalpres: Element | Builder
This stanza will be sent before disconnecting.
Private function to disconnect. Just closes the socket.
Private function to check if the message queue is empty.
True, because stanzas are written to the socket immediately.
Inspect the server's reply to our handshake. An empty <handshake/>
means success and the component is CONNECTED; a <stream:error/> (e.g.
<not-authorized/>) means the shared secret was wrong.
The first stanza received after sending the handshake.
Called on stream start/restart when no authentication mechanism is offered. Not reachable on the component path (there is no SASL), but kept for interface parity.
Optionalcallback: (this: default) => voidPrivate function to handle the socket closing.
Private function called when raw bytes arrive on the socket. Feeds them into the incremental stream parser.
The bytes received from the socket.
Private timeout handler for a non-graceful disconnection. Nothing to do for a plain TCP socket.
Private function to handle socket errors.
The socket error.
Private function called by Connection._onIdle
Serializes queued stanzas and writes them to the socket, stamping a
from attribute under the component's domain when one is absent (the
server validates that a component stamps from, per XEP-0114).
Private function to handle incoming stanzas once authenticated. Wraps the stanza and routes it through the normal handler machinery, exactly as Websocket#_onMessage does.
A complete top-level stanza element.
Private function to handle a successful TCP connection. Sends the component stream header (XEP-0114 §2).
Handle a fatal XML parse error on the inbound stream.
The parse error.
Route a complete inbound stanza. Before the handshake completes this is the handshake result; afterwards it's ordinary traffic.
A complete top-level stanza element.
Handle the closing </stream:stream> tag from the server.
Handle the server's opening stream header. Captures the stream id and replies with the SHA-1 handshake (XEP-0114 §3).
The attributes of the server's stream:stream header.
Reset the transport. Called by Connection#reset.
Private part of the Connection.send function for the component transport. Just flushes the messages that are in the queue.
Compute and send the XEP-0114 handshake digest,
hex( SHA1( STREAM_ID + SHARED_SECRET ) ) in lowercase.
The stream id from the server's stream header.
Send an xmpp:restart stanza.
Components never restart their stream, so this only flushes any queued data. Included for interface parity with the other transports.
Serialize an element to a string, reusing Strophe's own serializer so output matches the other transports.
Parse the component service URL into a host and port.
Accepts tcp://host:port (the recommended plaintext form) and tolerates a
bare host:port. The port defaults to 5347, the conventional component
listener port.
Ensure an outgoing stanza carries a from attribute under the
component's domain, which XEP-0114 requires the server to validate.
An explicit from (e.g. a sub-JID of the component) is left untouched.
The outgoing stanza element.
The opening <stream:stream> header sent to the server. to is the
component's own domain, per XEP-0114.
A self-closed representation of the stream header, purely for the
xmlOutput debug hook (the real header sent on the wire never closes).
Tear the connection down exactly once.
A single parsed chunk can surface several teardown triggers back to
back: a <stream:error/> immediately followed by the closing
</stream:stream>, or a socket error and then its close event. Each
would otherwise call Connection#_doDisconnect again and fire a
second DISCONNECTED. The first call through here wins; later ones are
no-ops.
A Status to report before disconnecting, or null to disconnect without a preceding status change (e.g. a plain stream close).
Optionalcondition: string
The accompanying error condition, if any.
Helper class that handles XEP-0114 external component connections.
Like Websocket it is used internally by Connection to encapsulate a session and is not meant to be used from user code. Select it with the
protocol: 'component'connection option and atcp://host:portservice URL.