A JavaScript library for XMPP BOSH/XMPP over Websocket.
This is the JavaScript version of the Strophe library. Since JavaScript had no facilities for persistent TCP connections, this library uses Bidirectional-streams Over Synchronous HTTP (BOSH) to emulate a persistent, stateful, two-way connection to an XMPP server. More information on BOSH can be found in XEP 124.
This version of Strophe also works with WebSockets. For more information on XMPP-over WebSocket see this RFC: http://tools.ietf.org/html/rfc7395
strophe.js | A JavaScript library for XMPP BOSH/XMPP over Websocket. |
Functions | |
$build | Create a Strophe.Builder. |
$msg | Create a Strophe.Builder with a <message/> element as the root. |
$iq | Create a Strophe.Builder with an <iq/> element as the root. |
$pres | Create a Strophe.Builder with a <presence/> element as the root. |
Strophe | An object container for all Strophe library functions. |
Constants | |
VERSION | The version of the Strophe library. |
XMPP Namespace Constants | Common namespace constants from the XMPP RFCs and XEPs. |
XHTML_IM Namespace | contains allowed tags, tag attributes, and css properties. |
Connection Status Constants | Connection status constants for use by the connection handler callback. |
Log Level Constants | Logging level indicators. |
Functions | |
addNamespace | This function is used to extend the current namespaces in Strophe.NS. |
forEachChild | Map a function over some or all child elements of a given element. |
isTagEqual | Compare an element’s tag name with a string. |
xmlGenerator | Get the DOM document to generate elements. |
xmlElement | Create an XML DOM element. |
xmlescape | Excapes invalid xml characters. |
xmlunescape | Unexcapes invalid xml characters. |
xmlTextNode | Creates an XML DOM text node. |
xmlHtmlNode | Creates an XML DOM html node. |
getText | Get the concatenation of all text children of an element. |
copyElement | Copy an XML DOM element. |
createHtml | Copy an HTML DOM element into an XML DOM. |
escapeNode | Escape the node part (also called local part) of a JID. |
unescapeNode | Unescape a node part (also called local part) of a JID. |
getNodeFromJid | Get the node portion of a JID String. |
getDomainFromJid | Get the domain portion of a JID String. |
getResourceFromJid | Get the resource portion of a JID String. |
getBareJidFromJid | Get the bare JID from a JID String. |
log | User overrideable logging function. |
debug | Log a message at the Strophe.LogLevel.DEBUG level. |
info | Log a message at the Strophe.LogLevel.INFO level. |
warn | Log a message at the Strophe.LogLevel.WARN level. |
error | Log a message at the Strophe.LogLevel.ERROR level. |
fatal | Log a message at the Strophe.LogLevel.FATAL level. |
serialize | Render a DOM element and all descendants to a String. |
addConnectionPlugin | Extends the Strophe.Connection object with the given plugin. |
Strophe. | XML DOM builder. |
Functions | |
Strophe. | Create a Strophe.Builder object. |
tree | Return the DOM tree. |
toString | Serialize the DOM tree to a String. |
up | Make the current parent element the new current element. |
attrs | Add or modify attributes of the current element. |
c | Add a child to the current element and make it the new current element. |
cnode | Add a child to the current element and make it the new current element. |
t | Add a child text element. |
h | Replace current element contents with the HTML passed in. |
Strophe. | XMPP Connection manager. |
Functions | |
Strophe. | Create and initialize a Strophe.Connection object. |
reset | Reset the connection. |
pause | Pause the request manager. |
resume | Resume the request manager. |
getUniqueId | Generate a unique ID for use in <iq/> elements. |
connect | Starts the connection process. |
Variables | |
authzid | Authorization identity. |
authcid | Authentication identity (User name). |
pass | Authentication identity (User password). |
servtype | Digest MD5 compatibility. |
Functions | |
attach | Attach to an already created and authenticated BOSH session. |
xmlInput | User overrideable function that receives XML data coming into the connection. |
xmlOutput | User overrideable function that receives XML data sent to the connection. |
rawInput | User overrideable function that receives raw data coming into the connection. |
rawOutput | User overrideable function that receives raw data sent to the connection. |
send | Send a stanza. |
flush | Immediately send any pending outgoing data. |
sendIQ | Helper function to send IQ stanzas. |
addTimedHandler | Add a timed handler to the connection. |
deleteTimedHandler | Delete a timed handler for a connection. |
addHandler | Add a stanza handler for the connection. |
deleteHandler | Delete a stanza handler for a connection. |
disconnect | Start the graceful disconnection process. |
authenticate | Set up authentication |
Strophe. | encapsulates SASL authentication mechanisms. |
Variables | |
priority | Determines which SASLMechanism is chosen for authentication (Higher is better). |
Functions | |
test | Checks if mechanism able to run. |
Constants | |
SASL mechanisms | Available authentication mechanisms |
Strophe.Bosh | Private helper class that handles BOSH Connections |
Files | |
bosh.js | A JavaScript library to enable BOSH in Strophejs. |
Variables | |
strip | BOSH-Connections will have all stanzas wrapped in a <body> tag when passed to Strophe.Connection.xmlInput or Strophe.Connection.xmlOutput. |
Strophe. | Private helper class that handles WebSocket Connections |
Files | |
websocket.js | A JavaScript library to enable XMPP over Websocket in Strophejs. |
An object container for all Strophe library functions.
This class is just a container for all the objects and constants used in the library. It is not meant to be instantiated, but to provide a namespace for library objects, constants, and functions.
Constants | |
VERSION | The version of the Strophe library. |
XMPP Namespace Constants | Common namespace constants from the XMPP RFCs and XEPs. |
XHTML_IM Namespace | contains allowed tags, tag attributes, and css properties. |
Connection Status Constants | Connection status constants for use by the connection handler callback. |
Log Level Constants | Logging level indicators. |
Functions | |
addNamespace | This function is used to extend the current namespaces in Strophe.NS. |
forEachChild | Map a function over some or all child elements of a given element. |
isTagEqual | Compare an element’s tag name with a string. |
xmlGenerator | Get the DOM document to generate elements. |
xmlElement | Create an XML DOM element. |
xmlescape | Excapes invalid xml characters. |
xmlunescape | Unexcapes invalid xml characters. |
xmlTextNode | Creates an XML DOM text node. |
xmlHtmlNode | Creates an XML DOM html node. |
getText | Get the concatenation of all text children of an element. |
copyElement | Copy an XML DOM element. |
createHtml | Copy an HTML DOM element into an XML DOM. |
escapeNode | Escape the node part (also called local part) of a JID. |
unescapeNode | Unescape a node part (also called local part) of a JID. |
getNodeFromJid | Get the node portion of a JID String. |
getDomainFromJid | Get the domain portion of a JID String. |
getResourceFromJid | Get the resource portion of a JID String. |
getBareJidFromJid | Get the bare JID from a JID String. |
log | User overrideable logging function. |
debug | Log a message at the Strophe.LogLevel.DEBUG level. |
info | Log a message at the Strophe.LogLevel.INFO level. |
warn | Log a message at the Strophe.LogLevel.WARN level. |
error | Log a message at the Strophe.LogLevel.ERROR level. |
fatal | Log a message at the Strophe.LogLevel.FATAL level. |
serialize | Render a DOM element and all descendants to a String. |
addConnectionPlugin | Extends the Strophe.Connection object with the given plugin. |
Common namespace constants from the XMPP RFCs and XEPs.
contains allowed tags, tag attributes, and css properties. Used in the createHtml function to filter incoming html into the allowed XHTML-IM subset. See http://xmpp.org
Connection status constants for use by the connection handler callback.
addNamespace: function ( name, value )
This function is used to extend the current namespaces in Strophe.NS. It takes a key and a value with the key being the name of the new namespace, with its actual value. For example: Strophe.addNamespace(‘PUBSUB’, “http://jabber.org/protocol/pubsub”);
(String) name | The name under which the namespace will be referenced under Strophe.NS |
(String) value | The actual namespace. |
forEachChild: function ( elem, elemName, func )
Map a function over some or all child elements of a given element.
This is a small convenience function for mapping a function over some or all of the children of an element. If elemName is null, all children will be passed to the function, otherwise only children whose tag names match elemName will be passed.
(XMLElement) elem | The element to operate on. |
(String) elemName | The child element tag name filter. |
(Function) func | The function to apply to each child. This function should take a single argument, a DOM element. |
xmlElement: function ( name )
Create an XML DOM element.
This function creates an XML DOM element correctly across all implementations. Note that these are not HTML DOM elements, which aren’t appropriate for XMPP stanzas.
(String) name | The name for the element. |
(Array|Object) attrs | An optional array or object containing key/value pairs to use as element attributes. The object should be in the format {‘key’: ‘value’} or {key: ‘value’}. The array should have the format [[‘key1’, ‘value1’], [‘key2’, ‘value2’]]. |
(String) text | The text child data for the element. |
A new XML DOM element.
User overrideable logging function.
This function is called whenever the Strophe library calls any of the logging functions. The default implementation of this function does nothing. If client code wishes to handle the logging messages, it should override this with
Strophe.log = function (level, msg) { (user code here) };
Please note that data sent and received over the wire is logged via Strophe.Connection.rawInput() and Strophe.Connection.rawOutput().
The different levels and their meanings are
DEBUG | Messages useful for debugging purposes. |
INFO | Informational messages. This is mostly information like ‘disconnect was called’ or ‘SASL auth succeeded’. |
WARN | Warnings about potential problems. This is mostly used to report transient connection errors like request timeouts. |
ERROR | Some error occurred. |
FATAL | A non-recoverable fatal error occurred. |
(Integer) level | The log level of the log message. This will be one of the values in Strophe.LogLevel. |
(String) msg | The log message. |
XML DOM builder.
This object provides an interface similar to JQuery but for building DOM element easily and rapidly. All the functions except for toString() and tree() return the object, so calls can be chained. Here’s an example using the $iq() builder helper.
$iq({to: 'you', from: 'me', type: 'get', id: '1'}) .c('query', {xmlns: 'strophe:example'}) .c('example') .toString()
The above generates this XML fragment
<iq to='you' from='me' type='get' id='1'> <query xmlns='strophe:example'> <example/> </query> </iq>
The corresponding DOM manipulations to get a similar fragment would be a lot more tedious and probably involve several helper variables.
Since adding children makes new operations operate on the child, up() is provided to traverse up the tree. To add two children, do
builder.c('child1', ...).up().c('child2', ...)
The next operation on the Builder will be relative to the second child.
Functions | |
Strophe. | Create a Strophe.Builder object. |
tree | Return the DOM tree. |
toString | Serialize the DOM tree to a String. |
up | Make the current parent element the new current element. |
attrs | Add or modify attributes of the current element. |
c | Add a child to the current element and make it the new current element. |
cnode | Add a child to the current element and make it the new current element. |
t | Add a child text element. |
h | Replace current element contents with the HTML passed in. |
Strophe.Builder = function ( name, attrs )
Create a Strophe.Builder object.
The attributes should be passed in object notation. For example
var b = new Builder('message', {to: 'you', from: 'me'});
or
var b = new Builder('messsage', {'xml:lang': 'en'});
(String) name | The name of the root element. |
(Object) attrs | The attributes for the root element in object notation. |
A new Strophe.Builder.
c: function ( name, attrs, text )
Add a child to the current element and make it the new current element.
This function moves the current element pointer to the child, unless text is provided. If you need to add another child, it is necessary to use up() to go back to the parent in the tree.
(String) name | The name of the child. |
(Object) attrs | The attributes of the child in object notation. |
(String) text | The text to add to the child. |
The Strophe.Builder object.
cnode: function ( elem )
Add a child to the current element and make it the new current element.
This function is the same as c() except that instead of using a name and an attributes object to create the child it uses an existing DOM element object.
(XMLElement) elem | A DOM element. |
The Strophe.Builder object.
XMPP Connection manager.
This class is the main part of Strophe. It manages a BOSH connection to an XMPP server and dispatches events to the user callbacks as data arrives. It supports SASL PLAIN, SASL DIGEST-MD5, SASL SCRAM-SHA1 and legacy authentication.
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().
Functions | |
Strophe. | Create and initialize a Strophe.Connection object. |
reset | Reset the connection. |
pause | Pause the request manager. |
resume | Resume the request manager. |
getUniqueId | Generate a unique ID for use in <iq/> elements. |
connect | Starts the connection process. |
Variables | |
authzid | Authorization identity. |
authcid | Authentication identity (User name). |
pass | Authentication identity (User password). |
servtype | Digest MD5 compatibility. |
Functions | |
attach | Attach to an already created and authenticated BOSH session. |
xmlInput | User overrideable function that receives XML data coming into the connection. |
xmlOutput | User overrideable function that receives XML data sent to the connection. |
rawInput | User overrideable function that receives raw data coming into the connection. |
rawOutput | User overrideable function that receives raw data sent to the connection. |
send | Send a stanza. |
flush | Immediately send any pending outgoing data. |
sendIQ | Helper function to send IQ stanzas. |
addTimedHandler | Add a timed handler to the connection. |
deleteTimedHandler | Delete a timed handler for a connection. |
addHandler | Add a stanza handler for the connection. |
deleteHandler | Delete a stanza handler for a connection. |
disconnect | Start the graceful disconnection process. |
authenticate | Set up authentication |
Strophe.Connection = function ( 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, e.g.
var conn = new Strophe.Connection("/http-bind/");
If you want to connect to the current host with a WebSocket connection you can tell Strophe to use WebSockets through a “protocol” attribute in the optional options parameter. Valid values are “ws” for WebSocket and “wss” for Secure WebSocket. So to connect to “wss://CURRENT_HOSTNAME/xmpp-websocket” you would call
var conn = new Strophe.Connection("/xmpp-websocket/", {protocol: "wss"});
Note that relative URLs NOT starting with a “/” will also include the path of the current site.
Also because downgrading security is not permitted by browsers, when using relative URLs both BOSH and WebSocket connections will use their secure variants if the current connection to the site is also secure (https).
by adding “sync” to the options, you can control if requests will be made synchronously or not. The default behaviour is asynchronous. If you want to make requests synchronous, make “sync” evaluate to true:
var conn = new Strophe.Connection("/http-bind/", {sync: true});
You can also toggle this on an already established connection:
conn.options.sync = true;
(String) service | The BOSH or WebSocket service URL. |
(Object) options | A hash of configuration options |
A new Strophe.Connection object.
pause: function ()
Pause the request manager.
This will prevent Strophe from sending any more requests to the server. This is very useful for temporarily pausing BOSH-Connections while a lot of send() calls are happening quickly. This causes Strophe to send the data in a single request, saving many request trips.
getUniqueId: function ( suffix )
Generate a unique ID for use in <iq/> elements.
All <iq/> stanzas are required to have unique id attributes. This function makes creating these easy. Each connection instance has a counter which starts from zero, and the value of this counter plus a colon followed by the suffix becomes the unique id. If no suffix is supplied, the counter is used as the unique id.
Suffixes are used to make debugging easier when reading the stream data, and their use is recommended. The counter resets to 0 for every new connection for the same reason. For connections to the same server that authenticate the same way, all the ids should be the same, which makes it easy to see changes. This is useful for automated testing as well.
(String) suffix | A optional suffix to append to the id. |
A unique string to be used for the id attribute.
connect: function ( jid, pass, callback, wait, hold, route )
Starts the connection process.
As the connection process proceeds, the user supplied callback will be triggered multiple times with status updates. The callback should take two arguments - the status code and the error condition.
The status code will be one of the values in the Strophe.Status constants. The error condition will be one of the conditions defined in RFC 3920 or the condition ‘strophe-parsererror’.
The Parameters wait, hold and route are optional and only relevant for BOSH connections. Please see XEP 124 for a more detailed explanation of the optional parameters.
(String) jid | The user’s JID. This may be a bare JID, or a full JID. If a node is not supplied, SASL ANONYMOUS authentication will be attempted. |
(String) pass | The user’s password. |
(Function) callback | The connect callback function. |
(Integer) wait | The optional HTTPBIND wait value. This is the time the server will wait before returning an empty result for a request. The default setting of 60 seconds is recommended. |
(Integer) hold | The optional HTTPBIND hold value. This is the number of connections the server will hold at one time. This should almost always be set to 1 (the default). |
(String) route | The optional route value. |
attach: function ( jid, sid, rid, callback, wait, hold, wind )
Attach to an already created and authenticated BOSH session.
This function is provided to allow Strophe to attach to BOSH sessions which have been created externally, perhaps by a Web application. This is often used to support auto-login type features without putting user credentials into the page.
(String) jid | The full JID that is bound by the session. |
(String) sid | The SID of the BOSH session. |
(String) rid | The current RID of the BOSH session. This RID will be used by the next request. (Function) callback The connect callback function. |
(Integer) wait | The optional HTTPBIND wait value. This is the time the server will wait before returning an empty result for a request. The default setting of 60 seconds is recommended. Other settings will require tweaks to the Strophe.TIMEOUT value. |
(Integer) hold | The optional HTTPBIND hold value. This is the number of connections the server will hold at one time. This should almost always be set to 1 (the default). |
(Integer) wind | The optional HTTBIND window value. This is the allowed range of request ids that are valid. The default is 5. |
User overrideable function that receives XML data coming into the connection.
The default function does nothing. User code can override this with
Strophe.Connection.xmlInput = function (elem) { (user code) };
Due to limitations of current Browsers’ XML-Parsers the opening and closing <stream> tag for WebSocket-Connoctions will be passed as selfclosing here.
BOSH-Connections will have all stanzas wrapped in a <body> tag. See Strophe.Bosh.strip if you want to strip this tag.
(XMLElement) elem | The XML data received by the connection. |
User overrideable function that receives XML data sent to the connection.
The default function does nothing. User code can override this with
Strophe.Connection.xmlOutput = function (elem) { (user code) };
Due to limitations of current Browsers’ XML-Parsers the opening and closing <stream> tag for WebSocket-Connoctions will be passed as selfclosing here.
BOSH-Connections will have all stanzas wrapped in a <body> tag. See Strophe.Bosh.strip if you want to strip this tag.
(XMLElement) elem | The XMLdata sent by the connection. |
send: function ( elem )
Send a stanza.
This function is called to push data onto the send queue to go out over the wire. Whenever a request is sent to the BOSH server, all pending data is sent and the queue is flushed.
(XMLElement | [XMLElement] | Strophe.Builder) elem - The stanza to send.
sendIQ: function( elem, callback, errback, timeout )
Helper function to send IQ stanzas.
(XMLElement) elem | The stanza to send. |
(Function) callback | The callback function for a successful request. |
(Function) errback | The callback function for a failed or timed out request. On timeout, the stanza will be null. |
(Integer) timeout | The time specified in milliseconds for a timeout to occur. |
The id used to send the IQ.
addTimedHandler: function ( period, handler )
Add a timed handler to the connection.
This function adds a timed handler. The provided handler will be called every period milliseconds until it returns false, the connection is terminated, or the handler is removed. Handlers that wish to continue being invoked should return true.
Because of method binding it is necessary to save the result of this function if you wish to remove a handler with deleteTimedHandler().
Note that user handlers are not active until authentication is successful.
(Integer) period | The period of the handler. |
(Function) handler | The callback function. |
A reference to the handler that can be used to remove it.
deleteTimedHandler: function ( handRef )
Delete a timed handler for a connection.
This function removes a timed handler from the connection. The handRef parameter is not the function passed to addTimedHandler(), but is the reference returned from addTimedHandler().
(Strophe.TimedHandler) handRef | The handler reference. |
addHandler: function ( handler, ns, name, type, id, from, options )
Add a stanza handler for the connection.
This function adds a stanza handler to the connection. The handler callback will be called for any stanza that matches the parameters. Note that if multiple parameters are supplied, they must all match for the handler to be invoked.
The handler will receive the stanza that triggered it as its argument. The handler should return true if it is to be invoked again; returning false will remove the handler after it returns.
As a convenience, the ns parameters applies to the top level element and also any of its immediate children. This is primarily to make matching /iq/query elements easy.
The options argument contains handler matching flags that affect how matches are determined. Currently the only flag is matchBare (a boolean). When matchBare is true, the from parameter and the from attribute on the stanza will be matched as bare JIDs instead of full JIDs. To use this, pass {matchBare: true} as the value of options. The default value for matchBare is false.
The return value should be saved if you wish to remove the handler with deleteHandler().
(Function) handler | The user callback. |
(String) ns | The namespace to match. |
(String) name | The stanza name to match. |
(String) type | The stanza type attribute to match. |
(String) id | The stanza id attribute to match. |
(String) from | The stanza from attribute to match. |
(String) options | The handler options |
A reference to the handler that can be used to remove it.
deleteHandler: function ( handRef )
Delete a stanza handler for a connection.
This function removes a stanza handler from the connection. The handRef parameter is not the function passed to addHandler(), but is the reference returned from addHandler().
(Strophe.Handler) handRef | The handler reference. |
disconnect: function ( reason )
Start the graceful disconnection process.
This function starts the disconnection process. This process starts by sending unavailable presence and sending BOSH body of type terminate. A timeout handler makes sure that disconnection happens even if the BOSH server does not respond. If the Connection object isn’t connected, at least tries to abort all pending requests so the connection object won’t generate successful requests (which were already opened).
The user supplied connection callback will be notified of the progress as this process happens.
(String) reason | The reason the disconnect is occuring. |
encapsulates SASL authentication mechanisms.
User code may override the priority for each mechanism or disable it completely. See priority for information about changing priority and test for informatian on how to disable a mechanism.
By default, all mechanisms are enabled and the priorities are
SCRAM-SHA1 | 40 |
DIGEST-MD5 | 30 |
Plain | 20 |
Variables | |
priority | Determines which SASLMechanism is chosen for authentication (Higher is better). |
Functions | |
test | Checks if mechanism able to run. |
Constants | |
SASL mechanisms | Available authentication mechanisms |
this.priority
Determines which SASLMechanism is chosen for authentication (Higher is better). Users may override this to prioritize mechanisms differently.
In the default configuration the priorities are
SCRAM-SHA1 | 40 |
DIGEST-MD5 | 30 |
Plain | 20 |
Example: (This will cause Strophe to choose the mechanism that the server sent first)
Strophe.SASLMD5.priority = Strophe.SASLSHA1.priority;
See SASL mechanisms for a list of available mechanisms.
Checks if mechanism able to run. To disable a mechanism, make this return false;
To disable plain authentication run
Strophe.SASLPlain.test = function() { return false; }
See SASL mechanisms for a list of available mechanisms.
(Strophe.Connection) connection | Target Connection. |
(Boolean) If mechanism was able to run.
Private helper class that handles BOSH Connections
The Strophe.Bosh class is used internally by Strophe.Connection to encapsulate BOSH sessions. It is not meant to be used from user’s code.
Files | |
bosh.js | A JavaScript library to enable BOSH in Strophejs. |
Variables | |
strip | BOSH-Connections will have all stanzas wrapped in a <body> tag when passed to Strophe.Connection.xmlInput or Strophe.Connection.xmlOutput. |
strip: null
BOSH-Connections will have all stanzas wrapped in a <body> tag when passed to Strophe.Connection.xmlInput or Strophe.Connection.xmlOutput. To strip this tag, User code can set Strophe.Bosh.strip to “body”:
Strophe.Bosh.prototype.strip = "body";
This will enable stripping of the body tag in both Strophe.Connection.xmlInput and Strophe.Connection.xmlOutput.
Private helper class that handles WebSocket Connections
The Strophe.WebSocket class is used internally by Strophe.Connection to encapsulate WebSocket sessions. It is not meant to be used from user’s code.
Files | |
websocket.js | A JavaScript library to enable XMPP over Websocket in Strophejs. |
A JavaScript library to enable XMPP over Websocket in Strophejs.
This file implements XMPP over WebSockets for Strophejs. If a Connection is established with a Websocket url (ws://...) Strophe will use WebSockets. For more information on XMPP-over WebSocket see this RFC draft: http://tools.ietf.org
WebSocket support implemented by Andreas Guth (andrea@rwth-aa chen.de) s.guth
Create a Strophe.Builder.
function $build( name, attrs )
Create a Strophe.Builder with a message/ element as the root.
function $msg( attrs )
Create a Strophe.Builder with an iq/ element as the root.
function $iq( attrs )
Create a Strophe.Builder with a presence/ element as the root.
function $pres( attrs )
This function is used to extend the current namespaces in Strophe.NS.
addNamespace: function ( name, value )
Map a function over some or all child elements of a given element.
forEachChild: function ( elem, elemName, func )
Compare an element’s tag name with a string.
isTagEqual: function ( el, name )
Get the DOM document to generate elements.
xmlGenerator: function ()
Create an XML DOM element.
xmlElement: function ( name )
Excapes invalid xml characters.
xmlescape: function( text )
Unexcapes invalid xml characters.
xmlunescape: function( text )
Creates an XML DOM text node.
xmlTextNode: function ( text )
Creates an XML DOM html node.
xmlHtmlNode: function ( html )
Get the concatenation of all text children of an element.
getText: function ( elem )
Copy an XML DOM element.
copyElement: function ( elem )
Copy an HTML DOM element into an XML DOM.
createHtml: function ( elem )
Escape the node part (also called local part) of a JID.
escapeNode: function ( node )
Unescape a node part (also called local part) of a JID.
unescapeNode: function ( node )
Get the node portion of a JID String.
getNodeFromJid: function ( jid )
Get the domain portion of a JID String.
getDomainFromJid: function ( jid )
Get the resource portion of a JID String.
getResourceFromJid: function ( jid )
Get the bare JID from a JID String.
getBareJidFromJid: function ( jid )
Log a message at the Strophe.LogLevel.DEBUG level.
debug: function( msg )
Log a message at the Strophe.LogLevel.INFO level.
info: function ( msg )
Log a message at the Strophe.LogLevel.WARN level.
warn: function ( msg )
Log a message at the Strophe.LogLevel.ERROR level.
error: function ( msg )
Log a message at the Strophe.LogLevel.FATAL level.
fatal: function ( msg )
Render a DOM element and all descendants to a String.
serialize: function ( elem )
Extends the Strophe.Connection object with the given plugin.
addConnectionPlugin: function ( name, ptype )
Create a Strophe.Builder object.
Strophe.Builder = function ( name, attrs )
Return the DOM tree.
tree: function ()
Serialize the DOM tree to a String.
toString: function ()
Make the current parent element the new current element.
up: function ()
Add or modify attributes of the current element.
attrs: function ( moreattrs )
Add a child to the current element and make it the new current element.
c: function ( name, attrs, text )
Add a child to the current element and make it the new current element.
cnode: function ( elem )
Add a child text element.
t: function ( text )
Replace current element contents with the HTML passed in.
h: function ( html )
Create and initialize a Strophe.Connection object.
Strophe.Connection = function ( service, options )
Reset the connection.
reset: function ()
Pause the request manager.
pause: function ()
Resume the request manager.
resume: function ()
Generate a unique ID for use in iq/ elements.
getUniqueId: function ( suffix )
Starts the connection process.
connect: function ( jid, pass, callback, wait, hold, route )
Authorization identity.
this.authzid
Authentication identity (User name).
this.authcid
Authentication identity (User password).
this.pass
Digest MD5 compatibility.
this.servtype
Attach to an already created and authenticated BOSH session.
attach: function ( jid, sid, rid, callback, wait, hold, wind )
Send a stanza.
send: function ( elem )
Immediately send any pending outgoing data.
flush: function ()
Helper function to send IQ stanzas.
sendIQ: function( elem, callback, errback, timeout )
Add a timed handler to the connection.
addTimedHandler: function ( period, handler )
Delete a timed handler for a connection.
deleteTimedHandler: function ( handRef )
Add a stanza handler for the connection.
addHandler: function ( handler, ns, name, type, id, from, options )
Delete a stanza handler for a connection.
deleteHandler: function ( handRef )
Start the graceful disconnection process.
disconnect: function ( reason )
Set up authentication
authenticate: function ( matched )
Determines which SASLMechanism is chosen for authentication (Higher is better).
this.priority
BOSH-Connections will have all stanzas wrapped in a body tag when passed to Strophe.Connection.xmlInput or Strophe.Connection.xmlOutput.
strip: null