Packageorg.igniterealtime.xiff.core
Classpublic class XMPPConnection
InheritanceXMPPConnection Inheritance flash.events.EventDispatcher
ImplementsIXMPPConnection
SubclassesXMPPBOSHConnection, XMPPTLSConnection

This class is used to connect to and manage data coming from an XMPP server. Use one instance of this class per connection.



Public Properties
 PropertyDefined by
  compress : Boolean
Shall the zlib compression be allowed if the server supports it.
XMPPConnection
  domain : String
The XMPP domain to use with the server.
XMPPConnection
  ignoreWhitespace : Boolean
Determines whether whitespace will be ignored on incoming XML data.
XMPPConnection
  incomingBytes : uint
[read-only] Get the count of the received bytes.
XMPPConnection
  jid : UnescapedJID
[read-only] Gets the fully qualified unescaped JID of the user.
XMPPConnection
  openConnections : Array
[static][read-only] Reference to all active connections.
XMPPConnection
  outgoingBytes : uint
[read-only] Get the count of current bytes sent by this connection
XMPPConnection
  password : String
The password to use when logging in.
XMPPConnection
  port : uint
The port to use when connecting.
XMPPConnection
  queuePresences : Boolean
Should the connection queue presence events for a small interval so that it can send multiple in a batch?
XMPPConnection
  resource : String
The resource to use when logging in.
XMPPConnection
  server : String
The XMPP server to use for connection.
XMPPConnection
  useAnonymousLogin : Boolean
Whether to use anonymous login or not.
XMPPConnection
  username : String
The username to use for connection.
XMPPConnection
Protected Properties
 PropertyDefined by
  active : Boolean
XMPPConnection
  _server : String
Server to connect, could be different of the login domain.
XMPPConnection
  socket : Socket
Binary socket used to connect to the XMPP server.
XMPPConnection
Public Methods
 MethodDefined by
  
Constructor.
XMPPConnection
  
changePassword(password:String):void
Changes the user's account password on the server.
XMPPConnection
  
connect(streamType:uint = 0):Boolean
Connects to the server.
XMPPConnection
  
disableSASLMechanism(name:String):void
[static] Remove a SASL mechanism.
XMPPConnection
  
disconnect():void
Disconnects from the server if currently connected.
XMPPConnection
  
Issues a request for the information that must be submitted for registration with the server.
XMPPConnection
  
isActive():Boolean
Determines whether the connection with the server is currently active.
XMPPConnection
  
isLoggedIn():Boolean
Determines whether the user is connected and logged into the server.
XMPPConnection
  
registerSASLMechanism(name:String, authClass:Class):void
[static] Add a SASL mechanism.
XMPPConnection
  
send(data:IXMPPStanza):void
Sends data to the server.
XMPPConnection
  
Sends ping to server in order to keep the connection alive.
XMPPConnection
  
sendRegistrationFields(fieldMap:Object, key:String):void
Registers a new account with the server, sending the registration data as specified in the fieldMap
XMPPConnection
Events
 EventSummaryDefined by
   Dispatched when a password change is successful.XMPPConnection
   Dispatched when the connection is successfully made to the server.XMPPConnection
   Dispatched when there is a disconnection from the server.XMPPConnection
   Dispatched when there is some type of XMPP error.XMPPConnection
   Dispatched whenever there is incoming XML data.XMPPConnection
   Dispatched on successful authentication (login) with the server.XMPPConnection
   Dispatched on incoming messages.XMPPConnection
   Dispatched whenever data is sent to the server.XMPPConnection
   Dispatched on incoming presence data.XMPPConnection
   Dispatched on when new user account registration is successful.XMPPConnection
Public Constants
 ConstantDefined by
  STREAM_TYPE_FLASH : uint = 2
[static] Stream type lets user set opening/closing tag.
XMPPConnection
  STREAM_TYPE_FLASH_TERMINATED : uint = 3
[static] Stream type lets user set opening/closing tag.
XMPPConnection
  STREAM_TYPE_STANDARD : uint = 0
[static] Stream type lets user set opening/closing tag.
XMPPConnection
  STREAM_TYPE_STANDARD_TERMINATED : uint = 1
[static] Stream type lets user set opening/closing tag.
XMPPConnection
Property detail
activeproperty
active:Boolean  [read-write]Implementation
    protected function get active():Boolean
    protected function set active(value:Boolean):void
compressproperty 
compress:Boolean  [read-write]

Shall the zlib compression be allowed if the server supports it.

The default value is false.

Implementation
    public function get compress():Boolean
    public function set compress(value:Boolean):void

See also

domainproperty 
domain:String  [read-write]

The XMPP domain to use with the server.

Implementation
    public function get domain():String
    public function set domain(value:String):void
ignoreWhitespaceproperty 
ignoreWhitespace:Boolean  [read-write]

Determines whether whitespace will be ignored on incoming XML data. Behaves the same as XML.ignoreWhitespace

Implementation
    public function get ignoreWhitespace():Boolean
    public function set ignoreWhitespace(value:Boolean):void
incomingBytesproperty 
incomingBytes:uint  [read-only]

Get the count of the received bytes.

Implementation
    public function get incomingBytes():uint
jidproperty 
jid:UnescapedJID  [read-only]

Gets the fully qualified unescaped JID of the user. A fully-qualified JID includes the resource. A bare JID does not. To get the bare JID, use the bareJID property of the UnescapedJID.

Implementation
    public function get jid():UnescapedJID

See also

openConnectionsproperty 
openConnections:Array  [read-only]

Reference to all active connections.

Implementation
    public static function get openConnections():Array
outgoingBytesproperty 
outgoingBytes:uint  [read-only]

Get the count of current bytes sent by this connection

Implementation
    public function get outgoingBytes():uint
passwordproperty 
password:String  [read-write]

The password to use when logging in.

Implementation
    public function get password():String
    public function set password(value:String):void
portproperty 
port:uint  [read-write]

The port to use when connecting. The default XMPP port is 5222.

Implementation
    public function get port():uint
    public function set port(value:uint):void
queuePresencesproperty 
queuePresences:Boolean  [read-write]

Should the connection queue presence events for a small interval so that it can send multiple in a batch?

The default value is true To maintain original behavior -- has to be explicitly set to false to disable..

Implementation
    public function get queuePresences():Boolean
    public function set queuePresences(value:Boolean):void
resourceproperty 
resource:String  [read-write]

The resource to use when logging in. A resource is required (defaults to "XIFF") and allows a user to login using the same account simultaneously (most likely from multiple machines). Typical examples of the resource include "Home" or "Office" to indicate the user's current location.

Implementation
    public function get resource():String
    public function set resource(value:String):void
_serverproperty 
protected var _server:String

Server to connect, could be different of the login domain.

serverproperty 
server:String  [read-write]

The XMPP server to use for connection.

Implementation
    public function get server():String
    public function set server(value:String):void
socketproperty 
protected var socket:Socket

Binary socket used to connect to the XMPP server.

useAnonymousLoginproperty 
useAnonymousLogin:Boolean  [read-write]

Whether to use anonymous login or not.

Implementation
    public function get useAnonymousLogin():Boolean
    public function set useAnonymousLogin(value:Boolean):void
usernameproperty 
username:String  [read-write]

The username to use for connection. If this property is null when connect() is called, the class will fetch registration field data rather than attempt to login.

Implementation
    public function get username():String
    public function set username(value:String):void
Constructor detail
XMPPConnection()constructor
public function XMPPConnection()

Constructor.

Method detail
changePassword()method
public function changePassword(password:String):void

Changes the user's account password on the server. If the password change is successful, the class will broadcast a ChangePasswordSuccessEvent.PASSWORD_SUCCESS event.

Parameters
password:String — The new password
connect()method 
public function connect(streamType:uint = 0):Boolean

Connects to the server. Use one of the STREAM_TYPE_.. constants. Possible options are:

Some servers, like Jabber, Inc.'s XCP and Jabberd 1.4 expect <flash:stream> from a Flash client instead of the standard <stream:stream>.

Parameters
streamType:uint (default = 0) — Any of the STREAM_TYPE_.. constants.

Returns
Boolean — A boolean indicating whether the server was found.
disableSASLMechanism()method 
public static function disableSASLMechanism(name:String):void

Remove a SASL mechanism.

Parameters
name:String
disconnect()method 
public function disconnect():void

Disconnects from the server if currently connected. After disconnect, a DisconnectionEvent.DISCONNECT event is broadcast.

See also

getRegistrationFields()method 
public function getRegistrationFields():void

Issues a request for the information that must be submitted for registration with the server. When the data returns, a RegistrationFieldsEvent.REG_FIELDS event is dispatched containing the requested data.

isActive()method 
public function isActive():Boolean

Determines whether the connection with the server is currently active. (Not necessarily logged in. For login status, use the isLoggedIn() method.)

Returns
Boolean — A boolean indicating whether the connection is active.

See also

isLoggedIn()method 
public function isLoggedIn():Boolean

Determines whether the user is connected and logged into the server.

Returns
Boolean — A boolean indicating whether the user is logged in.

See also

registerSASLMechanism()method 
public static function registerSASLMechanism(name:String, authClass:Class):void

Add a SASL mechanism.

Parameters
name:String
 
authClass:Class
send()method 
public function send(data:IXMPPStanza):void

Sends data to the server. If the data to send cannot be serialized properly, this method throws a SerializeException.

Parameters
data:IXMPPStanza — The data to send. This must be an instance of a class that implements the ISerializable interface.

See also


Example
The following example sends a basic chat message to the user with the JID "sideshowbob

sendKeepAlive()method 
public function sendKeepAlive():void

Sends ping to server in order to keep the connection alive.

sendRegistrationFields()method 
public function sendRegistrationFields(fieldMap:Object, key:String):void

Registers a new account with the server, sending the registration data as specified in the fieldMap

Parameters
fieldMap:Object — An object map containing the data to use for registration. The map should be composed of attribute:value pairs for each registration data item.
 
key:String — (Optional) If a key was passed in the "data" field of the "registrationFields" event, that key must also be passed here. required field needed for registration.
Event detail
changePasswordSuccessevent 
Event object type: org.igniterealtime.xiff.events.ChangePasswordSuccessEvent

Dispatched when a password change is successful.

connectionevent  
Event object type: org.igniterealtime.xiff.events.ConnectionSuccessEvent

Dispatched when the connection is successfully made to the server.

disconnectionevent  
Event object type: org.igniterealtime.xiff.events.DisconnectionEvent

Dispatched when there is a disconnection from the server.

errorevent  
Event object type: org.igniterealtime.xiff.events.XIFFErrorEvent

Dispatched when there is some type of XMPP error.

incomingDataevent  
Event object type: org.igniterealtime.xiff.events.IncomingDataEvent

Dispatched whenever there is incoming XML data.

loginevent  
Event object type: org.igniterealtime.xiff.events.LoginEvent

Dispatched on successful authentication (login) with the server.

messageevent  
Event object type: org.igniterealtime.xiff.events.MessageEvent

Dispatched on incoming messages.

outgoingDataevent  
Event object type: org.igniterealtime.xiff.events.OutgoingDataEvent

Dispatched whenever data is sent to the server.

presenceevent  
Event object type: org.igniterealtime.xiff.events.PresenceEvent

Dispatched on incoming presence data.

registrationSuccessevent  
Event object type: org.igniterealtime.xiff.events.RegistrationSuccessEvent

Dispatched on when new user account registration is successful.

Constant detail
STREAM_TYPE_FLASHconstant
public static const STREAM_TYPE_FLASH:uint = 2

Stream type lets user set opening/closing tag. <flash:stream>

STREAM_TYPE_FLASH_TERMINATEDconstant 
public static const STREAM_TYPE_FLASH_TERMINATED:uint = 3

Stream type lets user set opening/closing tag. <flash:stream />

STREAM_TYPE_STANDARDconstant 
public static const STREAM_TYPE_STANDARD:uint = 0

Stream type lets user set opening/closing tag. <stream:stream>

STREAM_TYPE_STANDARD_TERMINATEDconstant 
public static const STREAM_TYPE_STANDARD_TERMINATED:uint = 1

Stream type lets user set opening/closing tag. <stream:stream />