Class: JSJaCHttpPollingConnection

JSJaCHttpPollingConnection

Implementation of {@link http://www.xmpp.org/extensions/xep-0025.html HTTP Polling}

new JSJaCHttpPollingConnection

Instantiates an HTTP Polling session
Source:
  • JSJaCHttpPollingConnection.js, line 13

Extends

Members

oDbg :JSJaCDebugger

Reference to debugger interface (needs to implement method log)
Source:
  • JSJaCConnection.js, line 31

Methods

connect

Connect to a jabber/XMPP server.
Parameters:
Name Type Description
oArg Object The configuration to be used for connecting.
Properties
Name Type Argument Description
domain string The domain name of the XMPP service.
username string The username (nodename) to be logged in with.
resource string The resource to identify the login with.
password string The user's password.
allow_plain boolean <optional>
Whether to allow plain text logins.
register boolean <optional>
Whether to register a new account.
host string <optional>
The host to connect to which might be different from the domain given above. So some XMPP service might host the domain 'example.com' but might be located at the host 'jabber.example.com'. Normally such situations should be gracefully handled by using DNS SRV records. But in cases where this isn't available you can set the host manually here.
port int <optional>
The port of the manually given host from above.
secure boolean <optional>
Whether to only allow secured (i.e. encrypted) connections to the XMPP service.
authhost string <optional>
The host that handles the actualy authorization. There are cases where this is different from the settings above, e.g. if there's a service that provides anonymous logins at 'anon.example.org'.
authtype string <optional>
Must be one of 'sasl' (default), 'nonsasl', 'saslanon', 'anonymous', or 'x-facebook-platform'.
xmllang string <optional>
The requested language for this login. Typically XMPP server try to respond with error messages and the like in this language if available.
Source:
  • JSJaCConnection.js, line 115

connected

Tells whether this connection is connected
Source:
  • JSJaCConnection.js, line 217
Returns:
true if this connections is connected, false otherwise

disconnect

Disconnects from jabber server and terminates session (if applicable)
Source:
  • JSJaCConnection.js, line 222

getPollInterval

Gets current value of polling interval
Source:
  • JSJaCConnection.js, line 258
Returns:
Polling interval in milliseconds

isPolling

Tells whether this implementation of JSJaCConnection is polling Useful if it needs to be decided whether it makes sense to allow for adjusting or adjust the polling interval JSJaCConnection#setPollInterval
Source:
  • JSJaCHttpPollingConnection.js, line 34
Returns:
true if this is a polling connection, false otherwise.

registerHandler

Registers an event handler (callback) for this connection.

Note: All of the packet handlers for specific packets (like message_in, presence_in and iq_in) fire only if there's no callback associated with the id.

Example:
con.registerHandler('iq', 'query', 'jabber:iq:version', handleIqVersion);

Parameters:
Name Type Description
event String One of
  • onConnect - connection has been established and authenticated
  • onDisconnect - connection has been disconnected
  • onResume - connection has been resumed
  • onStatusChanged - connection status has changed, current status as being passed argument to handler. See #status.
  • onError - an error has occured, error node is supplied as argument, like this:
    <error code='404' type='cancel'>
    <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    </error>
  • packet_in - a packet has been received (argument: the packet)
  • packet_out - a packet is to be sent(argument: the packet)
  • message_in | message - a message has been received (argument: the packet)
  • message_out - a message packet is to be sent (argument: the packet)
  • presence_in | presence - a presence has been received (argument: the packet)
  • presence_out - a presence packet is to be sent (argument: the packet)
  • iq_in | iq - an iq has been received (argument: the packet)
  • iq_out - an iq is to be sent (argument: the packet)
childName String A childnode's name that must occur within a retrieved packet [optional]
childNS String A childnode's namespace that must occure within a retrieved packet (works only if childName is given) [optional]
type String The type of the packet to handle (works only if childName and chidNS are given (both may be set to '*' in order to get skipped) [optional]
handler Function The handler to be called when event occurs. If your handler returns 'true' it cancels bubbling of the event. No other registered handlers for this event will be fired.
Source:
  • JSJaCConnection.js, line 320

registerIQGet

Register for iq packets of type 'get'.
Parameters:
Name Type Description
childName String A childnode's name that must occur within a retrieved packet
childNS String A childnode's namespace that must occure within a retrieved packet (works only if childName is given)
handler Function The handler to be called when event occurs. If your handler returns 'true' it cancels bubbling of the event. No other registered handlers for this event will be fired.
Source:
  • JSJaCConnection.js, line 396

registerIQSet

Register for iq packets of type 'set'.
Parameters:
Name Type Description
childName String A childnode's name that must occur within a retrieved packet
childNS String A childnode's namespace that must occure within a retrieved packet (works only if childName is given)
handler Function The handler to be called when event occurs. If your handler returns 'true' it cancels bubbling of the event. No other registered handlers for this event will be fired.
Source:
  • JSJaCConnection.js, line 411

resume

Resumes this connection from saved state (cookie)
Source:
  • JSJaCConnection.js, line 421
Returns:
Whether resume was successful

resumeFromData

Resumes BOSH connection from data
Parameters:
Name Type Description
serialized Object jsjac state information
Source:
  • JSJaCConnection.js, line 438
Returns:
Whether resume was successful

send

Sends a JSJaCPacket
Parameters:
Name Type Description
packet JSJaCPacket The packet to send
cb Function The callback to be called if there's a reply to this packet (identified by id) [optional]
arg Object Arguments passed to the callback (additionally to the packet received) [optional]
Source:
  • JSJaCConnection.js, line 485
Returns:
'true' if sending was successfull, 'false' otherwise

sendIQ

Sends an IQ packet. Has default handlers for each reply type. Those maybe overriden by passing an appropriate handler.
Parameters:
Name Type Description
iq JSJaCIQPacket the iq packet to send
handlers Object object with properties 'error_handler', 'result_handler' and 'default_handler' with appropriate functions
arg Object argument to handlers
Source:
  • JSJaCConnection.js, line 529
Returns:
'true' if sending was successfull, 'false' otherwise

setPollInterval

Sets polling interval for this connection
Parameters:
Name Type Description
millisecs int Milliseconds to set timer to
Source:
  • JSJaCConnection.js, line 562
Returns:
effective interval this connection has been set to

status

Returns current status of this connection
Source:
  • JSJaCConnection.js, line 585
Returns:
String to denote current state. One of
  • 'initializing' ... well
  • 'connecting' if connect() was called
  • 'resuming' if resume() was called
  • 'processing' if it's about to operate as normal
  • 'onerror_fallback' if there was an error with the request object
  • 'protoerror_fallback' if there was an error at the http binding protocol flow (most likely that's where you interested in)
  • 'internal_server_error' in case of an internal server error
  • 'suspending' if suspend() is being called
  • 'aborted' if abort() was called
  • 'disconnecting' if disconnect() has been called

suspend

Suspends this connection (saving state for later resume) Saves state to cookie
Source:
  • JSJaCConnection.js, line 593
Returns:
Whether suspend (saving to cookie) was successful

suspendToData

Suspend connection and return serialized JSJaC connection state
Source:
  • JSJaCConnection.js, line 621
Returns:
JSJaC connection state object