Package tigase.xmpp
Class XMPPSession
- java.lang.Object
-
- tigase.xmpp.XMPPSession
-
public class XMPPSession extends java.lang.Object
XMPPSession class is a container class for allXMPPResourceConnection
objects for particular user (i.e. all user's connected resources)
-
-
Constructor Summary
Constructors Constructor Description XMPPSession(java.lang.String username)
Creates a newXMPPSession
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addResourceConnection(XMPPResourceConnection conn)
This method is called each time the resource is set for connection.java.lang.Object
computeCommonSessionDataIfAbsent(java.lang.String key, java.util.function.Function<java.lang.String,java.lang.Object> valueFactory)
java.util.List<XMPPResourceConnection>
getActiveResources()
Method returns a List of allXMPPResourceConnection
objects related to thisXMPPSession
objectjava.util.List<XMPPResourceConnection>
getActiveResourcesClone()
Method returns a cloned List of allXMPPResourceConnection
objects related to thisXMPPSession
objectint
getActiveResourcesSize()
Method returns number of allXMPPResourceConnection
objects related to thisXMPPSession
objectjava.lang.Object
getCommonSessionData(java.lang.String key)
Method returns a data for particularkey
which is common to all resource connections within thisXMPPSession
related to thisXMPPSession
objectJID[]
getConnectionIds()
Method returns an array of all ConnectionIDs related to thisXMPPSession
JID[]
getJIDs()
Method returns an array of all FullJIDs related to thisXMPPSession
long
getLiveTime()
Method returns time of how long the session is active (in milliseconds)long
getPacketsCounter()
Returns number of processed packet for the given user session (i.e. all users connections in total)XMPPResourceConnection
getResourceConnection(JID jid)
Method returnsXMPPResourceConnection
for particular FullJID.XMPPResourceConnection
getResourceForConnectionId(JID connectionId)
Method returnsXMPPResourceConnection
for particular ConnectionID.XMPPResourceConnection
getResourceForJID(JID jid)
Method returnsXMPPResourceConnection
for particular FullJID (usingresource
name as determinant.XMPPResourceConnection
getResourceForResource(java.lang.String resource)
Method returnsXMPPResourceConnection
for particularresource
.java.lang.String
getUserName()
Method returns username that is related to thisXMPPSession
(i.e. mostly localpart of JID)void
incPacketsCounter()
Increments counter of processed packet for the given user session (i.e. all users connections in total)protected void
putCommonSessionData(java.lang.String key, java.lang.Object value)
Method used to store data common for all connections of the user.protected java.lang.Object
putCommonSessionDataIfAbsent(java.lang.String key, java.lang.Object value)
protected java.lang.Object
removeCommonSessionData(java.lang.String key)
Method used to remove data common for all connections of the user.void
removeResourceConnection(XMPPResourceConnection conn)
Removes particularXMPPResourceConnection
user's resource connection from the list of all active user connections within givenXMPPSession
and detachesXMPPSession
from the removedXMPPResourceConnection
void
streamClosed(XMPPResourceConnection conn)
Method is called upon closing stream connection and removes particularXMPPResourceConnection
java.lang.String
toString()
-
-
-
Method Detail
-
addResourceConnection
public void addResourceConnection(XMPPResourceConnection conn) throws TigaseStringprepException
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
public void removeResourceConnection(XMPPResourceConnection conn)
Removes particularXMPPResourceConnection
user's resource connection from the list of all active user connections within givenXMPPSession
and detachesXMPPSession
from the removedXMPPResourceConnection
-
streamClosed
public void streamClosed(XMPPResourceConnection conn)
Method is called upon closing stream connection and removes particularXMPPResourceConnection
- Parameters:
conn
- -XMPPResourceConnection
for which stream was closed.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getActiveResources
public java.util.List<XMPPResourceConnection> getActiveResources()
Method returns a List of allXMPPResourceConnection
objects related to thisXMPPSession
object
-
getActiveResourcesClone
public java.util.List<XMPPResourceConnection> 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
public java.lang.Object getCommonSessionData(java.lang.String key)
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
public JID[] getConnectionIds()
Method returns an array of all ConnectionIDs related to thisXMPPSession
-
getJIDs
public JID[] 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
public XMPPResourceConnection getResourceConnection(JID jid)
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
public XMPPResourceConnection getResourceForConnectionId(JID connectionId)
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
public XMPPResourceConnection getResourceForJID(JID jid)
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
public XMPPResourceConnection getResourceForResource(java.lang.String resource)
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
public java.lang.String getUserName()
Method returns username that is related to thisXMPPSession
(i.e. mostly localpart of JID)
-
computeCommonSessionDataIfAbsent
public java.lang.Object computeCommonSessionDataIfAbsent(java.lang.String key, java.util.function.Function<java.lang.String,java.lang.Object> valueFactory)
-
putCommonSessionData
protected void putCommonSessionData(java.lang.String key, java.lang.Object value)
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
protected java.lang.Object putCommonSessionDataIfAbsent(java.lang.String key, java.lang.Object value)
-
removeCommonSessionData
protected java.lang.Object removeCommonSessionData(java.lang.String key)
Method used to remove data common for all connections of the user.- Parameters:
key
- for which data should be removed
-
-