Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.http
Class HttpSession

java.lang.Object
  extended by org.jivesoftware.wildfire.session.Session
      extended by org.jivesoftware.wildfire.session.ClientSession
          extended by org.jivesoftware.wildfire.http.HttpSession
All Implemented Interfaces:
ChannelHandler, RoutableChannelHandler

public class HttpSession
extends ClientSession

A session represents a serious of interactions with an XMPP client sending packets using the HTTP Binding protocol specified in XEP-0124. A session can have several client connections open simultaneously while awaiting packets bound for the client from the server.

Author:
Alexander Wenckus

Nested Class Summary
static class HttpSession.HttpVirtualConnection
          A virtual server connection relates to a http session which its self can relate to many http connections.
 
Field Summary
 
Fields inherited from class org.jivesoftware.wildfire.session.ClientSession
authToken
 
Fields inherited from class org.jivesoftware.wildfire.session.Session
CHARSET, conn, MAJOR_VERSION, MINOR_VERSION, sessionManager, status, STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED, STATUS_STREAMING
 
Constructor Summary
HttpSession(PacketDeliverer backupDeliverer, String serverName, InetAddress address, StreamID streamID, long rid)
           
 
Method Summary
 void addSessionCloseListener(SessionListener listener)
          Adds a SessionListener to this session.
 void close()
          Closes the session.
 String getAvailableStreamFeatures()
          Returns a text with the available stream features.
 Collection<org.dom4j.Element> getAvailableStreamFeaturesElements()
          Returns the stream features which are available for this session.
 int getHold()
          Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session.
 int getInactivityTimeout()
          Returns the time, in seconds, after which this session will be considered inactive and terminated.
 String getLanguage()
          Returns the language this session is using.
 long getLastActivity()
          Returns the time in milliseconds since the epoch that this session was last active.
 int getMaxPollingInterval()
          Returns the max interval within which a client can send polling requests.
 int getMaxRequests()
          Returns the max number of requests it is permissable for this session to have open at any one time.
 Collection<org.dom4j.Element> getPacketsToSend(long time, TimeUnit timeUnit)
          Returns the next set of packets to be sent.
 String getResponse(long requestID)
           
 int getWait()
          Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session.
 boolean isClosed()
          Returns true if this session has been closed and no longer activley accepting connections.
 boolean isSecure()
          Returns true if all connections on this session should be secured, and false if they should not.
 void releasePacketsToSend()
          Releases the lock on the send packets queue so that other threads may access it.
 void removeSessionCloseListener(SessionListener listener)
          Removes a SessionListener from this session.
 void setHold(int hold)
          Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session.
 void setInactivityTimeout(int inactivityTimeout)
          Sets the time, in seconds, after which this session will be considered inactive and be be terminated.
 void setLanaguage(String language)
          Sets the language this session is using.
 void setMaxPollingInterval(int maxPollingInterval)
          Sets the max interval within which a client can send polling requests.
 void setMaxRequests(int maxRequests)
          The max number of requests it is permissable for this session to have open at any one time.
protected  void setSecure(boolean isSecure)
          Sets whether the initial request on the session was secure.
 void setWait(int wait)
          Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session.
 
Methods inherited from class org.jivesoftware.wildfire.session.ClientSession
canFloodOfflineMessages, canProcess, createSession, getActiveList, getAllowedIPs, getAuthToken, getCompressionPolicy, getConflictCount, getDefaultList, getPresence, getTLSPolicy, getUsername, incrementConflictCount, isInitialized, isOfflineFloodStopped, setActiveList, setAllowedIPs, setAnonymousAuth, setAuthToken, setAuthToken, setCompressionPolicy, setDefaultList, setInitialized, setOfflineFloodStopped, setPresence, setTLSPolicy, toString, wasAvailable
 
Methods inherited from class org.jivesoftware.wildfire.session.Session
decodeVersion, getAddress, getConnection, getCreationDate, getLastActiveDate, getNumClientPackets, getNumServerPackets, getServerName, getSessionData, getStatus, getStreamID, incrementClientPacketCount, incrementServerPacketCount, process, removeSessionData, setAddress, setSessionData, setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpSession

public HttpSession(PacketDeliverer backupDeliverer,
                   String serverName,
                   InetAddress address,
                   StreamID streamID,
                   long rid)
Method Detail

getAvailableStreamFeaturesElements

public Collection<org.dom4j.Element> getAvailableStreamFeaturesElements()
Returns the stream features which are available for this session.

Returns:
the stream features which are available for this session.

getAvailableStreamFeatures

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

Overrides:
getAvailableStreamFeatures in class ClientSession
Returns:
a text with the available stream features or null to add nothing.

close

public void close()
Closes the session. After a session has been closed it will no longer accept new connections on the session ID.


isClosed

public boolean isClosed()
Returns true if this session has been closed and no longer activley accepting connections.

Returns:
true if this session has been closed and no longer activley accepting connections.

setWait

public void setWait(int wait)
Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session. This enables the client to prevent its TCP connection from expiring due to inactivity, as well as to limit the delay before it discovers any network failure.

Parameters:
wait - the longest time it is permissible to wait for a response.

getWait

public int getWait()
Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session. This enables the client to prevent its TCP connection from expiring due to inactivity, as well as to limit the delay before it discovers any network failure.

Returns:
the longest time it is permissible to wait for a response.

setHold

public void setHold(int hold)
Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session. (For example, if a constrained client is unable to keep open more than two HTTP connections to the same HTTP server simultaneously, then it SHOULD specify a value of "1".)

Parameters:
hold - the maximum number of simultaneous waiting requests.

getHold

public int getHold()
Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session. (For example, if a constrained client is unable to keep open more than two HTTP connections to the same HTTP server simultaneously, then it SHOULD specify a value of "1".)

Returns:
the maximum number of simultaneous waiting requests

setLanaguage

public void setLanaguage(String language)
Sets the language this session is using.

Parameters:
language - the language this session is using.

getLanguage

public String getLanguage()
Returns the language this session is using.

Returns:
the language this session is using.

setMaxPollingInterval

public void setMaxPollingInterval(int maxPollingInterval)
Sets the max interval within which a client can send polling requests. If more than one request occurs in the interval the session will be terminated.

Parameters:
maxPollingInterval - time in seconds a client needs to wait before sending polls to the server, a negative int indicates that there is no limit.

getMaxPollingInterval

public int getMaxPollingInterval()
Returns the max interval within which a client can send polling requests. If more than one request occurs in the interval the session will be terminated.

Returns:
the max interval within which a client can send polling requests. If more than one request occurs in the interval the session will be terminated.

setMaxRequests

public void setMaxRequests(int maxRequests)
The max number of requests it is permissable for this session to have open at any one time.

Parameters:
maxRequests - The max number of requests it is permissable for this session to have open at any one time.

getMaxRequests

public int getMaxRequests()
Returns the max number of requests it is permissable for this session to have open at any one time.

Returns:
the max number of requests it is permissable for this session to have open at any one time.

isSecure

public boolean isSecure()
Returns true if all connections on this session should be secured, and false if they should not.

Returns:
true if all connections on this session should be secured, and false if they should not.

addSessionCloseListener

public void addSessionCloseListener(SessionListener listener)
Adds a SessionListener to this session. The listener will be notified of changes to the session.

Parameters:
listener - the listener which is being added to the session.

removeSessionCloseListener

public void removeSessionCloseListener(SessionListener listener)
Removes a SessionListener from this session. The listener will no longer be updated when an event occurs on the session.

Parameters:
listener - the session listener that is to be removed.

setInactivityTimeout

public void setInactivityTimeout(int inactivityTimeout)
Sets the time, in seconds, after which this session will be considered inactive and be be terminated.

Parameters:
inactivityTimeout - the time, in seconds, after which this session will be considered inactive and be terminated.

getInactivityTimeout

public int getInactivityTimeout()
Returns the time, in seconds, after which this session will be considered inactive and terminated.

Returns:
the time, in seconds, after which this session will be considered inactive and terminated.

getLastActivity

public long getLastActivity()
Returns the time in milliseconds since the epoch that this session was last active. Activity is a request was either made or responded to. If the session is currently active, meaning there are connections awaiting a response, the current time is returned.

Returns:
the time in milliseconds since the epoch that this session was last active.

getResponse

public String getResponse(long requestID)
                   throws HttpBindException
Throws:
HttpBindException

setSecure

protected void setSecure(boolean isSecure)
Sets whether the initial request on the session was secure.

Parameters:
isSecure - true if the initial request was secure and false if it wasn't.

getPacketsToSend

public Collection<org.dom4j.Element> getPacketsToSend(long time,
                                                      TimeUnit timeUnit)
Returns the next set of packets to be sent. This method is meant to be used in the producer-consumer model to prevent deadlocks when processing incoming packets from the session. The internal packet queue is protected so that only one collection of packets can be sent at a time. This method will return null if packets are currently being consumed or there is no collection of packets waiting to be sent. After done consuming the packets releasePacketsToSend() needs to be called.

Parameters:
time - the quantity of time to wait for the queue to be free for consumption
timeUnit - the unit of time related to the quanity
Returns:
a collection of packets to be sent.

releasePacketsToSend

public void releasePacketsToSend()
Releases the lock on the send packets queue so that other threads may access it.


Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.