Class Index | Minimal

Classes


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:

Class Summary
Constructor Attributes Constructor Name and Description
 
jabberwerx.Client(resourceName)

Creates a new Client with the given (optional) resource.

Field Summary
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 Summary
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.

 
Destroys this client.
 
Disconnect from the server.
 
Gets all presence objects for the jid specified.
 
 

Retrieves the current presence for this client.

 
Gets the primary presence for the jid specified.
 
 

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)
 
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
Class Detail
jabberwerx.Client(resourceName)

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.
Field Detail
{Boolean} autoRegister
Whether auto-registration is active.

{Number} clientStatus
The current client status.

{jabberwerx.Server} connectedServer
The server to which we are currently connected.

{jabberwerx.User} connectedUser
The user with whose JID we are currently logged in.

controllers
The collection of registered Controllers for this Client. Controllers are responsible for registering themselves with their owning client.

{jabberwerx.EntitySet} entitySet
This entity set must be used to get references to any entity needed for the lifetime of this client/connection.

{jabberwerx.JID} fullJid
The full JID of the currently connected user as a jabberwerx.JID, null if not connected.This property is read only. Convenience property equivalent to jabberwerx.JID.asJID(client.connectUser.jid + "/" + client.resourceName). Note - this property will have a non-null value whenever connectedUser has been populated. fullJid will be available immediately after connect has been called (before actual connection is complete).

{String} resourceName
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 Detail
cancelReconnect()
Cancels a reconnect if one is currently in the pipeline. Triggers the reconnectCancelled event.

connect(jid, password, arg)

Connect to the XMPP server. the value of {arg} is expected to be an object with any of the following properties:

NameTypeDescription
httpBindingURLStringURL for BOSH connection
successCallbackFunctionCalled when the client successfully connects. It is expected to have the following signature:
function success() {
   this; //The client
}
errorCallbackFunctionCalled 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
}
unsecureAllowedBooleantrue 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.

destroy()
Destroys this client. This method walks through all of the controllers, destroying them.

disconnect()
Disconnect from the server.

{jabberwerx.Presence[]} getAllPresenceForEntity(jid)
Gets all presence objects for the jid specified. Usual usage would be for bare jids. If a full jid is passed through then only one presence object will be returned in the array.
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

{String} getClientStatusString(status)
Parameters:
{Number} status
A Client.status_... constant
Returns:
A string version of the status.

{jabberwerx.Presence} getCurrentPresence(primary)

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

{jabberwerx.Presence} getPrimaryPresenceForEntity(jid)
Gets the primary presence for the jid specified. If the jid is in bare jid format (ex. 'user@host') then the highest priority presence for that entity will be returned. If the jid is in full jid format (ex. 'user@host/resource') then the presence object for that resource only will be returned.
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

{Boolean} isConnected()
Returns:
Whether the client is currently connected

{Boolean} isSecure()

Determines if this client is connected in a secure or trusted manner.

Returns:
true If the stream is considered secure

{Array|Node} selectNodes(stanzaDoc, selector)
Runs the passed jQuery selector string against the passed stanza.
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.

{String} sendIq(type, to, content, callback, timeout)
Send an XMPP IQ stanza.
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.

sendIQ(type, to, content, callback, timeout)
Alias for jabberwerx.Client#sendIq.
Parameters:
type
to
content
callback
timeout

sendMessage(to, body, subject, type, thread)
Send an XMPP message. Assumes chat-type content with a body.
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.

sendPresence(show, status, to)
Send an XMPP presence stanza
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.

sendStanza(rootName, type, to, content)
Send an XMPP 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.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 02 2014 13:23:41 GMT-0600 (MDT)