Converse converse.js

Class: Connection

Strophe.Connection(service, options)

XMPP Connection manager

This class is the main part of Strophe. It manages a BOSH or websocket connection to an XMPP server and dispatches events to the user callbacks as data arrives.

It supports various authentication mechanisms (e.g. SASL PLAIN, SASL SCRAM), and more can be added via registerSASLMechanisms().

After creating a Strophe.Connection object, the user will typically call connect() with a user supplied callback to handle connection level events like authentication failure, disconnection, or connection complete.

The user will also have several event handlers defined by using addHandler() and addTimedHandler(). These will allow the user code to respond to interesting stanzas or do something periodically with the connection. These handlers will be active once authentication is finished.

To send data to the connection, use send().

Constructor

new Connection(service, options)

Create and initialize a Strophe.Connection object.

The transport-protocol for this connection will be chosen automatically based on the given service parameter. URLs starting with "ws://" or "wss://" will use WebSockets, URLs starting with "http://", "https://" or without a protocol will use BOSH.

To make Strophe connect to the current host you can leave out the protocol and host part and just pass the path:

const conn = new Strophe.Connection("/http-bind/");

Parameters:
Name Type Description
service string

The BOSH or WebSocket service URL.

options ConnectionOptions

A object containing configuration options

Source:

Members

_data

Source:

_sasl_data :SASLData

Type:
Source:

addHandlers :Array.<Handler>

Type:
Source:

addTimeds :Array.<TimedHandler>

Type:
  • Array.<TimedHandler>
Source:

handlers :Array.<Handler>

Type:
Source:

mechanisms :Object.<string, SASLMechanism>

Type:
Source:

removeHandlers :Array.<Handler>

Type:
Source:

removeTimeds :Array.<TimedHandler>

Type:
  • Array.<TimedHandler>
Source:

timedHandlers :Array.<TimedHandler>

Type:
  • Array.<TimedHandler>
Source: