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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method is called each time the resource is set for connection.computeCommonSessionDataIfAbsent
(String key, Function<String, Object> valueFactory) Method returns a List of allXMPPResourceConnection
objects related to thisXMPPSession
objectMethod returns a cloned List of allXMPPResourceConnection
objects related to thisXMPPSession
objectint
Method returns number of allXMPPResourceConnection
objects related to thisXMPPSession
objectMethod returns a data for particularkey
which is common to all resource connections within thisXMPPSession
related to thisXMPPSession
objectJID[]
Method returns an array of all ConnectionIDs related to thisXMPPSession
JID[]
getJIDs()
Method returns an array of all FullJIDs related to thisXMPPSession
long
Method returns time of how long the session is active (in milliseconds)long
Returns number of processed packet for the given user session (i.e.getResourceConnection
(JID jid) Method returnsXMPPResourceConnection
for particular FullJID.getResourceForConnectionId
(JID connectionId) Method returnsXMPPResourceConnection
for particular ConnectionID.getResourceForJID
(JID jid) Method returnsXMPPResourceConnection
for particular FullJID (usingresource
name as determinant.getResourceForResource
(String resource) Method returnsXMPPResourceConnection
for particularresource
.Method returns username that is related to thisXMPPSession
(i.e.void
Increments counter of processed packet for the given user session (i.e.protected void
putCommonSessionData
(String key, Object value) Method used to store data common for all connections of the user.protected Object
putCommonSessionDataIfAbsent
(String key, Object value) protected Object
Method used to remove data common for all connections of the user.void
Removes particularXMPPResourceConnection
user's resource connection from the list of all active user connections within givenXMPPSession
and detachesXMPPSession
from the removedXMPPResourceConnection
void
Method is called upon closing stream connection and removes particularXMPPResourceConnection
toString()
-
Constructor Details
-
XMPPSession
Creates a newXMPPSession
instance.- 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
-XMPPResourceConnection
that 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 particularXMPPResourceConnection
user's resource connection from the list of all active user connections within givenXMPPSession
and detachesXMPPSession
from the removedXMPPResourceConnection
-
streamClosed
Method is called upon closing stream connection and removes particularXMPPResourceConnection
- Parameters:
conn
- -XMPPResourceConnection
for which stream was closed.
-
toString
-
getActiveResources
Method returns a List of allXMPPResourceConnection
objects related to thisXMPPSession
object -
getActiveResourcesClone
Method returns a cloned List of allXMPPResourceConnection
objects related to thisXMPPSession
object -
getActiveResourcesSize
public int getActiveResourcesSize()Method returns number of allXMPPResourceConnection
objects related to thisXMPPSession
object -
getCommonSessionData
Method returns a data for particularkey
which is common to all resource connections within thisXMPPSession
related to thisXMPPSession
object- 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 returnsXMPPResourceConnection
for particular FullJID. In case there are no sessionsnull
is 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 aXMPPResourceConnection
should be returned
-
getResourceForConnectionId
Method returnsXMPPResourceConnection
for particular ConnectionID. In case there is no session that match given ConnectionID thennull
is returned.- Parameters:
connectionId
- ConnectionID for whichXMPPResourceConnection
should be returned
-
getResourceForJID
Method returnsXMPPResourceConnection
for particular FullJID (usingresource
name as determinant. In case there is no session that match -null
is returned.- Parameters:
jid
- FullJID for which aXMPPResourceConnection
should be returned
-
getResourceForResource
Method returnsXMPPResourceConnection
for particularresource
. In case there is no session that match -null
is returned.- Parameters:
resource
- resource string for which aXMPPResourceConnection
should 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
-