org.androidpn.server.xmpp.session
Class Session

java.lang.Object
  extended by org.androidpn.server.xmpp.session.Session
Direct Known Subclasses:
ClientSession

public abstract class Session
extends java.lang.Object

This is an abstract class for a session between the server and a client.

Author:
Sehwan Noh (devnoh@gmail.com)

Field Summary
static int STATUS_AUTHENTICATED
          The session status when authenticated
static int STATUS_CLOSED
          The session status when closed
static int STATUS_CONNECTED
          The session status when connected
 
Constructor Summary
Session(java.lang.String serverName, Connection conn, java.lang.String streamID)
          Constructor.
 
Method Summary
 void close()
          Close the session including associated socket connection.
 void deliver(org.xmpp.packet.Packet packet)
          Delivers the packet to the associated connection.
 void deliverRawText(java.lang.String text)
          Delivers raw text to the associated connection.
 org.xmpp.packet.JID getAddress()
          Returns the address of the user in JID.
abstract  java.lang.String getAvailableStreamFeatures()
          Returns a text with the available stream features.
 Connection getConnection()
          Returns the connection associated with this session.
 java.util.Date getCreationDate()
          Returns the creation date of this session.
 java.lang.String getHostAddress()
          Returns the IP address.
 java.lang.String getHostName()
          Gets the host name for the IP address.
 java.util.Date getLastActiveDate()
          Returns the last activity time of this session.
 long getNumClientPackets()
          Returns the number of packets sent from the client to the server.
 long getNumServerPackets()
          Returns the number of packets sent from the server to the client.
 java.lang.String getServerName()
          Returns the server name.
 int getStatus()
          Returns the current status of this session.
 java.lang.String getStreamID()
          Returns the stream ID associated with this sesison.
 void incrementClientPacketCount()
          Increments the number of packets sent from the client to the server.
 void incrementServerPacketCount()
          Increments the number of packets sent from the server to the client.
 boolean isClosed()
          Returns true if the connection is closed.
 void process(org.xmpp.packet.Packet packet)
          Process the packet.
 void setAddress(org.xmpp.packet.JID address)
          Sets the new address of this session.
 void setStatus(int status)
          Set the new status of this session.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_CLOSED

public static final int STATUS_CLOSED
The session status when closed

See Also:
Constant Field Values

STATUS_CONNECTED

public static final int STATUS_CONNECTED
The session status when connected

See Also:
Constant Field Values

STATUS_AUTHENTICATED

public static final int STATUS_AUTHENTICATED
The session status when authenticated

See Also:
Constant Field Values
Constructor Detail

Session

public Session(java.lang.String serverName,
               Connection conn,
               java.lang.String streamID)
Constructor. Creates a new JID using server name and stream ID.

Parameters:
serverName - the server name
conn - the connection
streamID - the stream ID
Method Detail

getConnection

public Connection getConnection()
Returns the connection associated with this session.

Returns:
the connection for this session

getServerName

public java.lang.String getServerName()
Returns the server name.

Returns:
the server name

getStreamID

public java.lang.String getStreamID()
Returns the stream ID associated with this sesison.

Returns:
the stream ID of this session

getAddress

public org.xmpp.packet.JID getAddress()
Returns the address of the user in JID.

Returns:
the address of this session

setAddress

public void setAddress(org.xmpp.packet.JID address)
Sets the new address of this session.

Parameters:
address - the new address of this session

getStatus

public int getStatus()
Returns the current status of this session.

Returns:
the status of this session

setStatus

public void setStatus(int status)
Set the new status of this session.

Parameters:
status - the new status of this session

getCreationDate

public java.util.Date getCreationDate()
Returns the creation date of this session.

Returns:
the creation date of this session

getLastActiveDate

public java.util.Date getLastActiveDate()
Returns the last activity time of this session.

Returns:
the last time of this session

incrementClientPacketCount

public void incrementClientPacketCount()
Increments the number of packets sent from the client to the server.


incrementServerPacketCount

public void incrementServerPacketCount()
Increments the number of packets sent from the server to the client.


getNumClientPackets

public long getNumClientPackets()
Returns the number of packets sent from the client to the server.

Returns:
the number of packets

getNumServerPackets

public long getNumServerPackets()
Returns the number of packets sent from the server to the client.

Returns:
the number of packets

process

public void process(org.xmpp.packet.Packet packet)
Process the packet.

Parameters:
packet - the packet to process

deliver

public void deliver(org.xmpp.packet.Packet packet)
Delivers the packet to the associated connection.

Parameters:
packet - the packet to deliver

deliverRawText

public void deliverRawText(java.lang.String text)
Delivers raw text to the associated connection.

Parameters:
text - the XML stanza string to deliver

close

public void close()
Close the session including associated socket connection.


isClosed

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

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

getHostAddress

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

Returns:
the IP address
Throws:
java.net.UnknownHostException

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

getAvailableStreamFeatures

public abstract java.lang.String getAvailableStreamFeatures()
Returns a text with the available stream features.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object