org.androidpn.server.xmpp.net
Class Connection

java.lang.Object
  extended by org.androidpn.server.xmpp.net.Connection

public class Connection
extends java.lang.Object

This class represents a XMPP connection on the server.

Author:
Sehwan Noh (devnoh@gmail.com)

Constructor Summary
Connection(org.apache.mina.core.session.IoSession ioSession)
          Constructor.
 
Method Summary
 void close()
          Closes the session including associated socket connection, notifing all listeners that the channel is shutting down.
 void deliver(org.xmpp.packet.Packet packet)
          Delivers the packet to this connection (without checking the recipient).
 void deliverRawText(java.lang.String text)
          Delivers raw text to this connection (in asynchronous mode).
 java.lang.String getHostAddress()
          Returns the IP address.
 java.lang.String getHostName()
          Gets the host name for the IP address.
 java.lang.String getLanguage()
          Returns the language code that should be used for this connection.
 int getMajorXMPPVersion()
          Returns the major version of XMPP being used by this connection.
 int getMinorXMPPVersion()
          Returns the minor version of XMPP being used by this connection.
 void init(Session session)
          Initializes the connection with it's owning session.
 boolean isClosed()
          Returns true if the connection is closed.
 void registerCloseListener(ConnectionCloseListener listener)
          Registers a listener for close event notification.
 void setLanaguage(java.lang.String language)
          Sets the language code that should be used for this connection.
 void setXMPPVersion(int majorVersion, int minorVersion)
          Sets the XMPP version information.
 void systemShutdown()
          Sends notification message indicating that the server is being shutdown.
 void unregisterCloseListener(ConnectionCloseListener listener)
          Removes a registered close event listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connection

public Connection(org.apache.mina.core.session.IoSession ioSession)
Constructor.

Parameters:
ioSession - the IoSession
Method Detail

close

public void close()
Closes the session including associated socket connection, notifing all listeners that the channel is shutting down.


systemShutdown

public void systemShutdown()
Sends notification message indicating that the server is being shutdown.


init

public void init(Session session)
Initializes the connection with it's owning session.

Parameters:
session - the session that owns this connection

isClosed

public boolean isClosed()
Returns true if the connection is closed.

Returns:
true if the connection is closed, false otherwise.

registerCloseListener

public void registerCloseListener(ConnectionCloseListener listener)
Registers a listener for close event notification.

Parameters:
listener - the listener to register for close events.

unregisterCloseListener

public void unregisterCloseListener(ConnectionCloseListener listener)
Removes a registered close event listener.

Parameters:
listener - the listener to unregister for close events.

deliver

public void deliver(org.xmpp.packet.Packet packet)
Delivers the packet to this connection (without checking the recipient).

Parameters:
packet - the packet to deliver

deliverRawText

public void deliverRawText(java.lang.String text)
Delivers raw text to this connection (in asynchronous mode).

Parameters:
text - the XML stanza string to deliver

getHostAddress

public java.lang.String getHostAddress()
                                throws java.net.UnknownHostException
Returns the IP address.

Returns:
the IP address
Throws:
java.net.UnknownHostException - if IP address of host could not be determined.

getHostName

public java.lang.String getHostName()
                             throws java.net.UnknownHostException
Gets the host name for the IP address.

Returns:
the host name for this IP address
Throws:
java.net.UnknownHostException - if IP address of host could not be determined.

getMajorXMPPVersion

public int getMajorXMPPVersion()
Returns the major version of XMPP being used by this connection.

Returns:
the major XMPP version

getMinorXMPPVersion

public int getMinorXMPPVersion()
Returns the minor version of XMPP being used by this connection.

Returns:
the minor XMPP version

setXMPPVersion

public void setXMPPVersion(int majorVersion,
                           int minorVersion)
Sets the XMPP version information.

Parameters:
majorVersion - the major version
minorVersion - the minor version

getLanguage

public java.lang.String getLanguage()
Returns the language code that should be used for this connection.

Returns:
the language code

setLanaguage

public void setLanaguage(java.lang.String language)
Sets the language code that should be used for this connection.

Parameters:
language - the language code