org.androidpn.server.xmpp.session
Class ClientSession

java.lang.Object
  extended by org.androidpn.server.xmpp.session.Session
      extended by org.androidpn.server.xmpp.session.ClientSession

public class ClientSession
extends Session

This class represents a session between the server and a client.

Author:
Sehwan Noh (devnoh@gmail.com)

Field Summary
 
Fields inherited from class org.androidpn.server.xmpp.session.Session
STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED
 
Constructor Summary
ClientSession(java.lang.String serverName, Connection connection, java.lang.String streamID)
          Constructor.
 
Method Summary
static ClientSession createSession(java.lang.String serverName, Connection connection, org.xmlpull.v1.XmlPullParser xpp)
          Creates a new session between the server and a client, and returns it.
 AuthToken getAuthToken()
          Returns the authentication token associated with this session.
 java.lang.String getAvailableStreamFeatures()
          Returns a text with the available stream features.
 org.xmpp.packet.Presence getPresence()
          Returns the presence of this session.
 java.lang.String getUsername()
          Returns the username associated with this session.
 boolean isInitialized()
          Indicates if the session has been initialized.
 void setAuthToken(AuthToken authToken, java.lang.String resource)
          Initialize the session with an authentication token and resource name.
 void setInitialized(boolean initialized)
          Sets the initialization state of the session.
 void setPresence(org.xmpp.packet.Presence presence)
          Sets the presence of this session.
 java.lang.String toString()
           
 boolean wasAvailable()
          Indicates if the session was available ever.
 
Methods inherited from class org.androidpn.server.xmpp.session.Session
close, deliver, deliverRawText, getAddress, getConnection, getCreationDate, getHostAddress, getHostName, getLastActiveDate, getNumClientPackets, getNumServerPackets, getServerName, getStatus, getStreamID, incrementClientPacketCount, incrementServerPacketCount, isClosed, process, setAddress, setStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientSession

public ClientSession(java.lang.String serverName,
                     Connection connection,
                     java.lang.String streamID)
Constructor.

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

createSession

public static ClientSession createSession(java.lang.String serverName,
                                          Connection connection,
                                          org.xmlpull.v1.XmlPullParser xpp)
                                   throws org.xmlpull.v1.XmlPullParserException
Creates a new session between the server and a client, and returns it.

Parameters:
serverName - the server name
connection - the connection
xpp - the XML parser to handle incoming data
Returns:
a newly created session
Throws:
org.xmlpull.v1.XmlPullParserException - if an error occurs while parsing incoming data

getUsername

public java.lang.String getUsername()
                             throws UserNotFoundException
Returns the username associated with this session.

Returns:
the username
Throws:
UserNotFoundException - if a user has not authenticated yet

getAuthToken

public AuthToken getAuthToken()
Returns the authentication token associated with this session.

Returns:
the authentication token

setAuthToken

public void setAuthToken(AuthToken authToken,
                         java.lang.String resource)
Initialize the session with an authentication token and resource name.

Parameters:
authToken - the authentication token
resource - the resource

isInitialized

public boolean isInitialized()
Indicates if the session has been initialized.

Returns:
true if the session has been initialized, false otherwise.

setInitialized

public void setInitialized(boolean initialized)
Sets the initialization state of the session.

Parameters:
initialized - true if the session has been initialized

wasAvailable

public boolean wasAvailable()
Indicates if the session was available ever.

Returns:
true if the session was available ever, false otherwise.

getPresence

public org.xmpp.packet.Presence getPresence()
Returns the presence of this session.

Returns:
the presence

setPresence

public void setPresence(org.xmpp.packet.Presence presence)
Sets the presence of this session.

Parameters:
presence - the presence

getAvailableStreamFeatures

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

Specified by:
getAvailableStreamFeatures in class Session

toString

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