Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.session
Class Session

java.lang.Object
  extended by org.jivesoftware.wildfire.session.Session
All Implemented Interfaces:
ChannelHandler, RoutableChannelHandler
Direct Known Subclasses:
ClientSession, ComponentSession, ConnectionMultiplexerSession, IncomingServerSession, OutgoingServerSession

public abstract class Session
extends Object
implements RoutableChannelHandler

The session represents a connection between the server and a client (c2s) or another server (s2s) as well as a connection with a component. Authentication and user accounts are associated with c2s connections while s2s has an optional authentication association but no single user user.

Obtain object managers from the session in order to access server resources.

Author:
Gaston Dombiak

Field Summary
protected  AuthToken authToken
          The authentication token for this session.
protected static String CHARSET
          The utf-8 charset for decoding and encoding Jabber packet streams.
protected  Connection conn
          The connection that this session represents.
static int MAJOR_VERSION
          Version of the XMPP spec supported as MAJOR_VERSION.MINOR_VERSION (e.g.
static int MINOR_VERSION
           
protected  SessionManager sessionManager
           
protected  int status
          The current session status.
static int STATUS_AUTHENTICATED
           
static int STATUS_CLOSED
           
static int STATUS_CONNECTED
           
static int STATUS_STREAMING
           
 
Constructor Summary
Session(String serverName, Connection connection, StreamID streamID)
          Creates a session with an underlying connection and permission protection.
 
Method Summary
protected static int[] decodeVersion(String version)
           
 JID getAddress()
          Obtain the address of the user.
abstract  String getAvailableStreamFeatures()
          Returns a text with the available stream features.
 Connection getConnection()
          Returns the connection associated with this Session.
 Date getCreationDate()
          Obtain the date the session was created.
 Date getLastActiveDate()
          Obtain the time the session last had activity.
 long getNumClientPackets()
          Obtain the number of packets sent from the client to the server.
 long getNumServerPackets()
          Obtain the number of packets sent from the server to the client.
 String getServerName()
          Obtain the name of the server this session belongs to.
 Object getSessionData(String key)
          Retrieves session data.
 int getStatus()
          Obtain the current status of this session.
 StreamID getStreamID()
          Obtain 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.
 void process(Packet packet)
          Process an XMPP packet.
 void removeSessionData(String key)
          Removes session data.
 void setAddress(JID address)
          Sets the new address of this session.
 void setSessionData(String key, Object value)
          Saves given session data.
 void setStatus(int status)
          Set the new status of this session.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAJOR_VERSION

public static final int MAJOR_VERSION
Version of the XMPP spec supported as MAJOR_VERSION.MINOR_VERSION (e.g. 1.0).

See Also:
Constant Field Values

MINOR_VERSION

public static final int MINOR_VERSION
See Also:
Constant Field Values

CHARSET

protected static String CHARSET
The utf-8 charset for decoding and encoding Jabber packet streams.


STATUS_CLOSED

public static final int STATUS_CLOSED
See Also:
Constant Field Values

STATUS_CONNECTED

public static final int STATUS_CONNECTED
See Also:
Constant Field Values

STATUS_STREAMING

public static final int STATUS_STREAMING
See Also:
Constant Field Values

STATUS_AUTHENTICATED

public static final int STATUS_AUTHENTICATED
See Also:
Constant Field Values

status

protected int status
The current session status.


conn

protected Connection conn
The connection that this session represents.


authToken

protected AuthToken authToken
The authentication token for this session.


sessionManager

protected SessionManager sessionManager
Constructor Detail

Session

public Session(String serverName,
               Connection connection,
               StreamID streamID)
Creates a session with an underlying connection and permission protection.

Parameters:
connection - The connection we are proxying
Method Detail

getAddress

public JID getAddress()
Obtain the address of the user. The address is used by services like the core server packet router to determine if a packet should be sent to the handler. Handlers that are working on behalf of the server should use the generic server hostname address (e.g. server.com).

Specified by:
getAddress in interface RoutableChannelHandler
Returns:
the address of the packet handler.

setAddress

public void setAddress(JID address)
Sets the new address of this session. The address is used by services like the core server packet router to determine if a packet should be sent to the handler. Handlers that are working on behalf of the server should use the generic server hostname address (e.g. server.com).


getConnection

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

Returns:
The connection for this session

getStatus

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

Returns:
The status code for this session

setStatus

public void setStatus(int status)
Set the new status of this session. Setting a status may trigger certain events to occur (setting a closed status will close this session).

Parameters:
status - The new status code for this session

getStreamID

public StreamID getStreamID()
Obtain the stream ID associated with this sesison. Stream ID's are generated by the server and should be unique and random.

Returns:
This session's assigned stream ID

getServerName

public String getServerName()
Obtain the name of the server this session belongs to.

Returns:
the server name.

getCreationDate

public Date getCreationDate()
Obtain the date the session was created.

Returns:
the session's creation date.

getLastActiveDate

public Date getLastActiveDate()
Obtain the time the session last had activity.

Returns:
The last time the session received activity.

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()
Obtain the number of packets sent from the client to the server.

Returns:
The number of packets sent from the client to the server.

getNumServerPackets

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

Returns:
The number of packets sent from the server to the client.

setSessionData

public void setSessionData(String key,
                           Object value)
Saves given session data. Data are saved to temporary storage only and are accessible during this session life only and only from this session instance.

Parameters:
key - a String value of stored data key ID.
value - a Object value of data stored in session.
See Also:
getSessionData(String)

getSessionData

public Object getSessionData(String key)
Retrieves session data. This method gives access to temporary session data only. You can retrieve earlier saved data giving key ID to receive needed value. Please see setSessionData(String, Object) description for more details.

Parameters:
key - a String value of stored data ID.
Returns:
a Object value of data for given key.
See Also:
setSessionData(String, Object)

removeSessionData

public void removeSessionData(String key)
Removes session data. Please see setSessionData(String, Object) description for more details.

Parameters:
key - a String value of stored data ID.
See Also:
setSessionData(String, Object)

process

public void process(Packet packet)
Description copied from interface: ChannelHandler
Process an XMPP packet.

Specified by:
process in interface ChannelHandler
Parameters:
packet - a packet to process.

getAvailableStreamFeatures

public abstract String getAvailableStreamFeatures()
Returns a text with the available stream features. Each subclass may return different values depending whether the session has been authenticated or not.

Returns:
a text with the available stream features or null to add nothing.

toString

public String toString()
Overrides:
toString in class Object

decodeVersion

protected static int[] decodeVersion(String version)

Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.