Packageorg.igniterealtime.xiff.core
Classpublic class XMPPBOSHConnection
InheritanceXMPPBOSHConnection Inheritance XMPPConnection Inheritance flash.events.EventDispatcher
Implements IXMPPConnection

XEP-0124: Bidirectional-streams Over Synchronous HTTP (BOSH) and XEP-0206: XMPP Over BOSH.

Using BOSH does not prevent your application from respecting Adobe Flash Player policy file issues. HTTP requests to your server must be authorized with a crossdomain.xml file in your webserver root.

Warning: if you are using BOSH through HTTPS, your crossdomain policy file must also be served through HTTPS. Your application (if online) must also be served through HTTPS else you will have a crossdomain policy issue. This issue can be solved by using the secure property of the allow-access-from node in the crossdomain.xml file. But this is not recommended by Adobe.

If your crossdomain policy file cannot be served by your server, this issue could be solved with an Apache proxy redirect so that any automatic Flash/Flex calls to an URL like http://xmppserver:5280/crossdomain.xml will be redirected as an URL of your choice such as http://webserver/crossdomain.xml.

See also

http://xmpp.org/extensions/xep-0124.html
http://xmpp.org/extensions/xep-0206.html


Public Properties
 PropertyDefined By
 Inheritedactive : Boolean
Determines whether the connection with the server is currently active.
XMPPConnection
  boshPath : String
Local part of the address in which the server responds.
XMPPBOSHConnection
 Inheritedcompress : Boolean
Shall the Stream Compression be allowed if the server supports it.
XMPPConnection
 Inheritedcompressor : ICompressor
The class that is to be used for Stream Compression if enabled.
XMPPConnection
 Inheriteddomain : String
The XMPP domain to use with the server.
XMPPConnection
  hold : uint
This attribute specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session.
XMPPBOSHConnection
  httpServer : String
[read-only] Server URI
XMPPBOSHConnection
 InheritedincomingBytes : uint
[read-only] Get the total count of the received bytes in the current session.
XMPPConnection
 Inheritedjid : UnescapedJID
[read-only] Gets the fully qualified unescaped JID of the user.
XMPPConnection
 InheritedloggedIn : Boolean
Determines whether the user is connected and logged into the server.
XMPPConnection
  maxConcurrentRequests : uint
Defaults to 2.
XMPPBOSHConnection
 InheritedopenConnections : Array
[static] [read-only] Reference to all active connections.
XMPPConnection
 InheritedoutgoingBytes : uint
[read-only] Get the total count of the bytes sent in the current session.
XMPPConnection
 Inheritedpassword : String
The password to use when logging in.
XMPPConnection
 Inheritedport : uint
The port to use when connecting.
XMPPConnection
 InheritedqueuePresences : Boolean
Should the connection queue presence events for a small interval so that it can send multiple in a batch?
XMPPConnection
 InheritedregistrationSupported : Boolean
[read-only] Does the connection support registration.
XMPPConnection
 Inheritedresource : String
The resource to use when logging in.
XMPPConnection
  secure : Boolean
HTTP bind requests type.
XMPPBOSHConnection
 Inheritedserver : String
The XMPP server to use for connection.
XMPPConnection
 InheriteduseAnonymousLogin : Boolean
Whether to use anonymous login or not.
XMPPConnection
 Inheritedusername : String
The username to use for connection.
XMPPConnection
  wait : uint
This attribute specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session.
XMPPBOSHConnection
Protected Properties
 PropertyDefined By
 InheritedclosingStreamTag : String
Depending of the STREAM_TYPE_used in the connect() method, this variable will contain a matching closing element for it.
XMPPConnection
 Inherited_compressor : ICompressor = null
Static class that is used to handle the compression
XMPPConnection
 InheritedexpireTagSearch : Boolean = false
Once received data from the socket, should the closing tag be seached? Initially this should be true as for the first incoming data there might be an error available.
XMPPConnection
 InheritedfeaturesAvailable : XML
Features as provided by the server, in their original XML form.
XMPPConnection
 InheritedopeningStreamTag : String
Opening part of the stream tag, such as <stream:stream or <flash:stream
XMPPConnection
 InheritedpendingIQs : Object
Hash to hold callbacks for IQs
XMPPConnection
 InheritedpingNotSupported : Boolean
Server supports keeping the connection alive with Ping extension
XMPPConnection
 InheritedpresenceQueue : Array
List of incoming presences that are waiting to be dispatched
XMPPConnection
 Inherited_registrationSupported : Boolean = false
XMPPConnection
 Inherited_server : String
Server to connect, could be different of the login domain.
XMPPConnection
 Inheritedsocket : Socket
Binary socket used to connect to the XMPP server.
XMPPConnection
 InheritedstreamTagSearch : String = stream:stream
Depending of the STREAM_TYPE_used in the connect() method, the name of the opening tag for stream is saved in this variable, such as stream:stream or flash:stream.
XMPPConnection
 InheritedtlsEnabled : Boolean = false
XMPPConnection
 InheritedtlsRequired : Boolean = false
Even if this class is not implementing TLS, it needs to be aware if it has been extended by XMPPTLSConnection that will set this value to true.
XMPPConnection
Public Methods
 MethodDefined By
  
XMPPBOSHConnection(secure:Boolean = false)
TLS compression (as defined in RFC 3920) and Stream Compression (as defined in Stream Compression [XEP-0138]) are NOT RECOMMENDED in BOSH since compression SHOULD be negotiated at the HTTP layer using the 'accept' attribute of the BOSH session creation response.
XMPPBOSHConnection
  
connect(streamType:uint = 0):void
[override] The first request from the client to the connection manager requests a new session.
XMPPBOSHConnection
 Inherited
disableExtensions(... exts):void
Disable the given extensions from the registery.
XMPPConnection
 Inherited
disableSASLMechanism(name:String):void
Remove a SASL mechanism from this connection
XMPPConnection
  
disconnect():void
[override]
XMPPBOSHConnection
 Inherited
enableExtensions(... exts):void
Enable the given extensions for interacting with the incoming data.
XMPPConnection
 Inherited
enableSASLMechanism(name:String, authClass:Class):void
Add a SASL mechanism available for this connection
XMPPConnection
  
pauseSession(seconds:uint):Boolean
XMPPBOSHConnection
  
processConnectionResponse(responseBody:XML):void
Session Creation Response After receiving a new session request, the connection manager MUST generate an opaque, unpredictable session identifier (or SID).
XMPPBOSHConnection
 Inherited
send(data:IXMPPStanza):void
Sends data to the server.
XMPPConnection
  
[override] Does nothing, BOSH uses polling instead.
XMPPBOSHConnection
Protected Methods
 MethodDefined By
 Inherited
SASL Authentication should been set up, begin the authentication process by sending the initial request.
XMPPConnection
 Inherited
Upon being so informed that resource binding is required, the client MUST bind a resource to the stream by sending to the server an IQ stanza of type "set" (see IQ Semantics (Section 9.2.3)) containing data qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' namespace.
XMPPConnection
 Inherited
checkIncomingData(bytedata:ByteArray):XML
Check if the incoming data is complete once added to any existing incoming data.
XMPPConnection
 Inherited
chooseStreamTags(type:uint):void
Choose the stream start and ending tags based on the given type.
XMPPConnection
 Inherited
configureAuthMechanisms(mechanisms:XML):void
Use the authentication which is first in the list (saslMechanisms) if possible.
XMPPConnection
 Inherited
configureStreamCompression(method:String = zlib):void
Zlib is the most common and the one which is required to be implemented in case Stream Compression is used.
XMPPConnection
 Inherited
Set up the connection and listeners related to this class.
XMPPConnection
 Inherited
dispatchError(condition:String, message:String, type:String, code:int = 0, extension:Extension = null):void
XMPPConnection
 Inherited
Runs after binding
XMPPConnection
 Inherited
flushPresenceQueue(event:TimerEvent):void
Dispatches a single PresenceEvent in case there are any in the queue.
XMPPConnection
 Inherited
handleAuthentication(response:XML):void
Upon receiving a success indication within the SASL negotiation, the client MUST send a new stream header to the server, to which the server MUST respond with a stream header as well as a list of available stream features.
XMPPConnection
 Inherited
handleMessage(node:XML):void
TODO: Add similar extension handling as in IQ, after message specific extensions are separated from Message class, v3.2.0
XMPPConnection
  
handleNodeType(node:XML):void
[override] TODO: Is this somthing that could be safely removed?
XMPPBOSHConnection
 Inherited
Handle the incoming Presence either with the queue timer or directly dispatching the PresenceEvent.
XMPPConnection
 Inherited
handleStream(node:XML):void
Initial stream element has been received once this method is called.
XMPPConnection
 Inherited
handleStreamError(node:XML):void
Handle stream error related element.
XMPPConnection
 Inherited
handleStreamFeatures(node:XML):void
Handle features that are available in the connected server.
XMPPConnection
 Inherited
handleStreamTLS(node:XML):void
Checks if the TLS feature available is required or not and dispatches an error in case it is.
XMPPConnection
 Inherited
onIOError(event:IOErrorEvent):void
This fires the standard dispatchError method
XMPPConnection
 Inherited
parseDataReceived(bytedata:ByteArray):void
Parses the data which the socket just received.
XMPPConnection
 Inherited
Remove those listeners that the createConnection method added.
XMPPConnection
  
[override] Upon receiving the success element, the client MUST then ask the connection manager to restart the stream by sending a "restart request".
XMPPBOSHConnection
 Inherited
sendData(data:String):void
Dispatches OutgoingDataEvent, handles possible Stream Compression and calls sendDataToServer.
XMPPConnection
  
sendDataToServer(data:ByteArray):void
[override] Connection to the server in BOSH is a simple URLRequest.
XMPPBOSHConnection
  
sendXML(data:String):void
[override] Pass through to sendRequests method for having the body wrapper around the given data.
XMPPBOSHConnection
 Inherited
Send a response to the Service Discovery query.
XMPPConnection
Events
 Event Summary Defined By
 Inherited
Dispatched on incoming IQ data that has an enabled extension.XMPPConnection
 InheritedDispatched when the connection is successfully made to the server.XMPPConnection
 InheritedDispatched when there is a disconnection from the server.XMPPConnection
 InheritedDispatched when there is some type of XMPP error.XMPPConnection
 InheritedDispatched whenever there is incoming XML data.XMPPConnection
 InheritedDispatched on successful authentication (login) with the server.XMPPConnection
 InheritedDispatched on incoming messages.XMPPConnection
 InheritedDispatched whenever data is sent to the server.XMPPConnection
 InheritedDispatched on incoming presence data.XMPPConnection
Public Constants
 ConstantDefined By
  BOSH_NS : String = http://jabber.org/protocol/httpbind
[static] Namespace used by BOSH body wrapper
XMPPBOSHConnection
  BOSH_VERSION : String = 1.6
[static] Current version of the BOSH defined in the XEP and the version which this class implements.
XMPPBOSHConnection
  ELEMENT_NAME : String = body
[static] BOSH body wrapper element name
XMPPBOSHConnection
  HTTP_PORT : uint = 7070
[static] The default port as per XMPP specification.
XMPPBOSHConnection
  HTTPS_PORT : uint = 7443
[static] The default secure port as per XMPP specification.
XMPPBOSHConnection
 InheritedSTREAM_TYPE_FLASH : uint = 2
[static] Stream type lets user set opening/closing tag.
XMPPConnection
 InheritedSTREAM_TYPE_FLASH_TERMINATED : uint = 3
[static] Stream type lets user set opening/closing tag.
XMPPConnection
 InheritedSTREAM_TYPE_STANDARD : uint = 0
[static] Stream type lets user set opening/closing tag.
XMPPConnection
 InheritedSTREAM_TYPE_STANDARD_TERMINATED : uint = 1
[static] Stream type lets user set opening/closing tag.
XMPPConnection
Protected Constants
 ConstantDefined By
 InheritedsaslMechanisms : Object
The types of SASL mechanisms available.
XMPPConnection
Property Detail
boshPathproperty
boshPath:String

Local part of the address in which the server responds.

The default value is http-bind/.


Implementation
    public function get boshPath():String
    public function set boshPath(value:String):void
holdproperty 
hold:uint

This attribute specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session. If the client is not able to use HTTP Pipelining then this SHOULD be set to "1".


Implementation
    public function get hold():uint
    public function set hold(value:uint):void
httpServerproperty 
httpServer:String  [read-only]

Server URI


Implementation
    public function get httpServer():String
maxConcurrentRequestsproperty 
maxConcurrentRequests:uint

Defaults to 2. Value retrieved from the server once stream is initiating.


Implementation
    public function get maxConcurrentRequests():uint
    public function set maxConcurrentRequests(value:uint):void
secureproperty 
secure:Boolean

HTTP bind requests type. If secure, the requests will be sent through HTTPS. If not, through HTTP.

Please note that the port needs to be set separately.


Implementation
    public function get secure():Boolean
    public function set secure(value:Boolean):void
waitproperty 
wait:uint

This attribute specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session. This enables the client to limit the delay before it discovers any network failure, and to prevent its HTTP/TCP connection from expiring due to inactivity.


Implementation
    public function get wait():uint
    public function set wait(value:uint):void
Constructor Detail
XMPPBOSHConnection()Constructor
public function XMPPBOSHConnection(secure:Boolean = false)

TLS compression (as defined in RFC 3920) and Stream Compression (as defined in Stream Compression [XEP-0138]) are NOT RECOMMENDED in BOSH since compression SHOULD be negotiated at the HTTP layer using the 'accept' attribute of the BOSH session creation response.

TLS compression and Stream Compression SHOULD NOT be used at the same time as HTTP content encoding.

Parameters
secure:Boolean (default = false) — Determines which port is used
Method Detail
connect()method
override public function connect(streamType:uint = 0):void

The first request from the client to the connection manager requests a new session.

The body element of the first request SHOULD possess the following attributes (they SHOULD NOT be included in any other requests except as specified under Adding Streams To A Session):

Note: Clients that only support Polling Sessions MAY prevent the connection manager from waiting by setting 'wait' or 'hold' to "0". However, polling is NOT RECOMMENDED since the associated increase in bandwidth consumption and the decrease in responsiveness are both typically one or two orders of magnitude!

Parameters

streamType:uint (default = 0) — Not used

See also

disconnect()method 
override public function disconnect():void

See also

handleNodeType()method 
override protected function handleNodeType(node:XML):void

TODO: Is this somthing that could be safely removed?

Parameters

node:XML

pauseSession()method 
public function pauseSession(seconds:uint):Boolean

Parameters

seconds:uint

Returns
Boolean — true if pause request is sent
processConnectionResponse()method 
public function processConnectionResponse(responseBody:XML):void

Session Creation Response

After receiving a new session request, the connection manager MUST generate an opaque, unpredictable session identifier (or SID). The SID MUST be unique within the context of the connection manager application. The body element of the connection manager's response to the client's session creation request MUST possess the following attributes (they SHOULD NOT be included in any other responses):

The body element SHOULD also include the following attributes (they SHOULD NOT be included in any other responses):

The connection manager MAY include an 'accept' attribute in the session creation response element, to specify a space-separated list of the content encodings it can decompress. After receiving a session creation response with an 'accept' attribute, clients MAY include an HTTP Content-Encoding header in subsequent requests (indicating one of the encodings specified in the 'accept' attribute) and compress the bodies of the requests accordingly.

Parameters

responseBody:XML

See also

restartStream()method 
override protected function restartStream():void

Upon receiving the success element, the client MUST then ask the connection manager to restart the stream by sending a "restart request".

sendDataToServer()method 
override protected function sendDataToServer(data:ByteArray):void

Connection to the server in BOSH is a simple URLRequest.

All information is encoded in the body of standard HTTP POST requests and responses. Each HTTP body contains a single body wrapper which encapsulates the XML elements being transferred.

BOSH requires all incoming and outgoing data to be wrapped in body element. That should be taken care of before possible Stream Compression.

Parameters

data:ByteArray — ByteArray that might be compressed if enabled

See also

sendKeepAlive()method 
override public function sendKeepAlive():void

Does nothing, BOSH uses polling instead.

sendXML()method 
override protected function sendXML(data:String):void

Pass through to sendRequests method for having the body wrapper around the given data.

Parameters

data:String

Constant Detail
BOSH_NSConstant
public static const BOSH_NS:String = http://jabber.org/protocol/httpbind

Namespace used by BOSH body wrapper

BOSH_VERSIONConstant 
public static const BOSH_VERSION:String = 1.6

Current version of the BOSH defined in the XEP and the version which this class implements.

The default value is 1.6.

ELEMENT_NAMEConstant 
public static const ELEMENT_NAME:String = body

BOSH body wrapper element name

HTTP_PORTConstant 
public static const HTTP_PORT:uint = 7070

The default port as per XMPP specification.

The default value is 7070.

HTTPS_PORTConstant 
public static const HTTPS_PORT:uint = 7443

The default secure port as per XMPP specification.

The default value is 7443.