Package tigase.xmpp
Class XMPPSession
java.lang.Object
tigase.xmpp.XMPPSession
XMPPSession class is a container class for all
XMPPResourceConnection objects for particular user (i.e. all
user's connected resources)-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called each time the resource is set for connection.computeCommonSessionDataIfAbsent(String key, Function<String, Object> valueFactory) Method returns a List of allXMPPResourceConnectionobjects related to thisXMPPSessionobjectMethod returns a cloned List of allXMPPResourceConnectionobjects related to thisXMPPSessionobjectintMethod returns number of allXMPPResourceConnectionobjects related to thisXMPPSessionobjectMethod returns a data for particularkeywhich is common to all resource connections within thisXMPPSession
related to thisXMPPSessionobjectJID[]Method returns an array of all ConnectionIDs related to thisXMPPSessionJID[]getJIDs()Method returns an array of all FullJIDs related to thisXMPPSessionlongMethod returns time of how long the session is active (in milliseconds)longReturns number of processed packet for the given user session (i.e.getResourceConnection(JID jid) Method returnsXMPPResourceConnectionfor particular FullJID.getResourceForConnectionId(JID connectionId) Method returnsXMPPResourceConnectionfor particular ConnectionID.getResourceForJID(JID jid) Method returnsXMPPResourceConnectionfor particular FullJID (usingresourcename as determinant.getResourceForResource(String resource) Method returnsXMPPResourceConnectionfor particularresource.Method returns username that is related to thisXMPPSession(i.e.voidIncrements counter of processed packet for the given user session (i.e.protected voidputCommonSessionData(String key, Object value) Method used to store data common for all connections of the user.protected ObjectputCommonSessionDataIfAbsent(String key, Object value) protected ObjectMethod used to remove data common for all connections of the user.voidRemoves particularXMPPResourceConnectionuser's resource connection from the list of all active user connections within givenXMPPSessionand detachesXMPPSessionfrom the removedXMPPResourceConnectionvoidMethod is called upon closing stream connection and removes particularXMPPResourceConnectiontoString()
-
Constructor Details
-
XMPPSession
Creates a newXMPPSessioninstance.- Parameters:
username- - localpart of user's JID
-
-
Method Details
-
addResourceConnection
This method is called each time the resource is set for connection.
Method performs checking whether there is no collision of the resources.- Parameters:
conn-XMPPResourceConnectionthat is being added.- Throws:
TigaseStringprepException
-
incPacketsCounter
public void incPacketsCounter()Increments counter of processed packet for the given user session (i.e. all users connections in total) -
removeResourceConnection
Removes particularXMPPResourceConnectionuser's resource connection from the list of all active user connections within givenXMPPSessionand detachesXMPPSessionfrom the removedXMPPResourceConnection -
streamClosed
Method is called upon closing stream connection and removes particularXMPPResourceConnection- Parameters:
conn- -XMPPResourceConnectionfor which stream was closed.
-
toString
-
getActiveResources
Method returns a List of allXMPPResourceConnectionobjects related to thisXMPPSessionobject -
getActiveResourcesClone
Method returns a cloned List of allXMPPResourceConnectionobjects related to thisXMPPSessionobject -
getActiveResourcesSize
public int getActiveResourcesSize()Method returns number of allXMPPResourceConnectionobjects related to thisXMPPSessionobject -
getCommonSessionData
Method returns a data for particularkeywhich is common to all resource connections within thisXMPPSession
related to thisXMPPSessionobject- Parameters:
key- for which data should be returned
-
getConnectionIds
Method returns an array of all ConnectionIDs related to thisXMPPSession -
getJIDs
Method returns an array of all FullJIDs related to thisXMPPSession -
getLiveTime
public long getLiveTime()Method returns time of how long the session is active (in milliseconds) -
getPacketsCounter
public long getPacketsCounter()Returns number of processed packet for the given user session (i.e. all users connections in total) -
getResourceConnection
Method returnsXMPPResourceConnectionfor particular FullJID. In case there are no sessionsnullis returned, in case there is more than one active session a session with the highest priority is returned. In case there are still more than one connections with the same priority then the latest active one is returned.- Parameters:
jid- FullJID for which aXMPPResourceConnectionshould be returned
-
getResourceForConnectionId
Method returnsXMPPResourceConnectionfor particular ConnectionID. In case there is no session that match given ConnectionID thennullis returned.- Parameters:
connectionId- ConnectionID for whichXMPPResourceConnectionshould be returned
-
getResourceForJID
Method returnsXMPPResourceConnectionfor particular FullJID (usingresourcename as determinant. In case there is no session that match -nullis returned.- Parameters:
jid- FullJID for which aXMPPResourceConnectionshould be returned
-
getResourceForResource
Method returnsXMPPResourceConnectionfor particularresource. In case there is no session that match -nullis returned.- Parameters:
resource- resource string for which aXMPPResourceConnectionshould be returned
-
getUserName
Method returns username that is related to thisXMPPSession(i.e. mostly localpart of JID) -
computeCommonSessionDataIfAbsent
-
putCommonSessionData
Method used to store data common for all connections of the user.- Parameters:
key- under which data should be storevalue- data to be stored
-
putCommonSessionDataIfAbsent
-
removeCommonSessionData
Method used to remove data common for all connections of the user.- Parameters:
key- for which data should be removed
-