Class jabberwerx.Client (MINIMAL)
Extends
jabberwerx.JWModel.
The role of the Client is to provide an interface to the XMPP protocol. It sends and recieves communication over its connection on behalf of any other model objects.
This class provides the following events:
Constructor Attributes | Constructor Name and Description |
---|---|
jabberwerx.Client(resourceName)
Creates a new Client with the given (optional) resource. |
Field Attributes | Field Name and Description |
---|---|
Whether auto-registration is active.
|
|
The current client status.
|
|
The server to which we are currently connected.
|
|
The user with whose JID we are currently logged in.
|
|
The collection of registered Controllers for this Client.
|
|
This entity set must be used to get references to any entity needed for the lifetime of this client/connection.
|
|
The full JID of the currently connected user as a jabberwerx.JID, null if
not connected.This property is read only.
|
|
The resource name for this client.
|
|
<static> <constant> |
jabberwerx.Client.status_connected
|
<static> <constant> |
jabberwerx.Client.status_connecting
|
<static> <constant> |
jabberwerx.Client.status_disconnected
|
<static> <constant> |
jabberwerx.Client.status_disconnecting
|
<static> <constant> |
jabberwerx.Client.status_reconnecting
|
Method Attributes | Method Name and Description |
---|---|
Cancels a reconnect if one is currently in the pipeline.
|
|
connect(jid, password, arg)
Connect to the XMPP server. |
|
destroy()
Destroys this client.
|
|
Disconnect from the server.
|
|
Gets all presence objects for the jid specified.
|
|
getClientStatusString(status)
|
|
getCurrentPresence(primary)
Retrieves the current presence for this client. |
|
Gets the primary presence for the jid specified.
|
|
isSecure()
Determines if this client is connected in a secure or trusted manner. |
|
selectNodes(stanzaDoc, selector)
Runs the passed jQuery selector string against the passed stanza.
|
|
sendIq(type, to, content, callback, timeout)
Send an XMPP IQ stanza.
|
|
sendIQ(type, to, content, callback, timeout)
Alias for jabberwerx.Client#sendIq.
|
|
sendMessage(to, body, subject, type, thread)
Send an XMPP message.
|
|
sendPresence(show, status, to)
Send an XMPP presence stanza
|
|
sendStanza(rootName, type, to, content)
Send an XMPP stanza.
|
- Methods borrowed from class jabberwerx.JWModel:
- applyEvent, event, shouldBeSavedWithGraph
- Methods borrowed from class jabberwerx.JWBase:
- getClassName, graphUnserialized, init, invocation, shouldBeSerializedInline, toString, wasUnserialized, willBeSerialized
Creates a new Client with the given (optional) resource. If {resourceName} is omitted, the client will rely on the XMPP/BOSH service to provide an appropriate value upon connection.
- Parameters:
- {String} resourceName Optional
- the client resource name to use.
Connect to the XMPP server. the value of {arg} is expected to be an object with any of the following properties:
Name | Type | Description |
---|---|---|
httpBindingURL | String | URL for BOSH connection |
successCallback | Function | Called when
the client successfully connects. It is expected to have the
following signature:
function success() { this; //The client } |
errorCallback | Function | Called when
the client fails to connect. It is expected to have the
following signature:
function failed(err) { this; //The client err; //An object describing the error } |
unsecureAllowed | Boolean | true if plaintext authentication is allowed over unencrypted or unsecured HTTP channels (defaults to false) |
NOTE: it is NOT RECOMMENDED to set "unsecureAllowed" to "true" outside of prototype code. Instead, The httpBindingURL should point to an HTTPS service and/or the origin page loaded over HTTPS.
- Parameters:
- {jabberwerx.JID|String} jid
- The JID to connect to the XMPP server. If anonymous login is required, only specify the domain as the jid i.e. "example.com"
- {String} password Optional
- The password for the given JID. If using anonymous login (i.e. the domain is passed as the jid value) the password argument is optional.
- {Object} arg
- Object containing the arguments to connect with.
- Parameters:
- {String|jabberwerx.JID} jid
- The jid to get all presence for
- Returns:
- An array of jabberwerx.Presence objects. Note that this array may be empty if no presence objects are attached to this jid's entity
- Parameters:
- {Number} status
- A Client.status_... constant
- Returns:
- A string version of the status.
Retrieves the current presence for this client. If not connected, this method returns null.
- Parameters:
- {Boolean} primary Optional
- Optional flag which, if true, this method will return the primary presence for this client. If false or not specified, the resource presence is retrieved.
- Returns:
- {jabberwerx.Presence} The current presence, or null if none
- Parameters:
- {String|jabberwerx.JID} jid
- The jid to get the primary presence of
- Returns:
- The primary presence or null if the entity / resource for this jid does not exist
- Returns:
- Whether the client is currently connected
Determines if this client is connected in a secure or trusted manner.
- Returns:
- true If the stream is considered secure
- Parameters:
- {String} stanzaDoc
- XML of stanza
- {String} selector
- jQuery selector
- Returns:
- A bare array (not jQuery-enhanced) of matching nodes, or a single node if only one matches.
- Parameters:
- {String} type
- The type attribute to set on the iq.
- {String} to
- The to attribute to set on the iq.
- {String} content
- XML content of the iq stanza.
- {Function} callback Optional
- A callback to be invoked when an IQ is recieved with a matching id. This includes error stanzas. If {timeout} is reached, a remote-server-timeout error is used.
- {Number} timeout Optional
- A timeout (in seconds) wait on a result or error IQ with a matching id
- Throws:
- TypeError If {callback} is defined and is not a function; or if {timeout} is defined and not a number
- Returns:
- The id set on the outgoing stanza.
- Parameters:
- type
- to
- content
- callback
- timeout
- Parameters:
- {String} to
- The to attribute to set on the message.
- {String} body
- The body of the message.
- {String} subject Optional
- The subject of the message
- {String} type Optional
- The type attribute to set on the message.
- {String} thread Optional
- A thread identifier, if any.
- Parameters:
- {String} show Optional
- Optional show value: 'away', 'available', 'dnd', etc.
- {String} status Optional
- Optional status message.
- {String} to Optional
- Optional `to` attribute to set on the outgoing stanza.
If {rootName} is an instance of jabberwerx.Stanza, this method ignores all other properties and sends the stanza directly. Otherwise, it is expected to be the name of the root node (e.g. presence, iq, message).
- Parameters:
- {jabberwerx.Stanza|Element|String} rootName
- The name of the root node (presence, iq, etc), or the object representation of the stanza.
- {String} type
- The type attribute to set on the root, if any. (Set to '' or null to not set a type).
- {String} to
- The to attribute to set on the root, if any. (Set to '' or null to not set a type).
- {String} content
- XML content of the stanza.