public class XMPPSession extends Object
XMPPResourceConnection
objects for
particular user (i.e. all user's connected resources)Constructor and Description |
---|
XMPPSession(String username)
Creates a new
XMPPSession instance. |
Modifier and Type | Method and Description |
---|---|
void |
addResourceConnection(XMPPResourceConnection conn)
This method is called each time the resource is set for connection.
|
protected Object |
computeCommonSessionDataIfAbsent(String key,
java.util.function.Function<String,Object> valueFactory) |
List<XMPPResourceConnection> |
getActiveResources()
Method returns a List of all
XMPPResourceConnection objects related
to this XMPPSession object |
List<XMPPResourceConnection> |
getActiveResourcesClone()
Method returns a cloned List of all
XMPPResourceConnection objects
related to this XMPPSession object |
int |
getActiveResourcesSize()
Method returns number of all
XMPPResourceConnection objects
related to this XMPPSession object |
Object |
getCommonSessionData(String key)
Method returns a data for particular
key which is common to all resource
connections within this XMPPSession
related to this XMPPSession object |
JID[] |
getConnectionIds()
Method returns an array of all ConnectionIDs related to this
XMPPSession |
JID[] |
getJIDs()
Method returns an array of all FullJIDs related to this
XMPPSession |
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 returns
XMPPResourceConnection for particular FullJID. |
XMPPResourceConnection |
getResourceForConnectionId(JID connectionId)
Method returns
XMPPResourceConnection for particular ConnectionID. |
XMPPResourceConnection |
getResourceForJID(JID jid)
Method returns
XMPPResourceConnection for particular FullJID (using
resource name as determinant. |
XMPPResourceConnection |
getResourceForResource(String resource)
Method returns
XMPPResourceConnection for particular
resource . |
String |
getUserName()
Method returns username that is related to this
XMPPSession (i.e. |
void |
incPacketsCounter()
Increments counter of processed packet for the given
user session (i.e. all users connections in total)
|
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 |
removeCommonSessionData(String key)
Method used to remove data common for all connections of the user.
|
void |
removeResourceConnection(XMPPResourceConnection conn)
Removes particular
XMPPResourceConnection user's resource connection
from the list of all active user connections within given XMPPSession
and detaches XMPPSession from the removed XMPPResourceConnection |
void |
streamClosed(XMPPResourceConnection conn)
Method is called upon closing stream connection and removes particular
XMPPResourceConnection |
String |
toString() |
public XMPPSession(String username)
XMPPSession
instance.username
- - localpart of user's JIDpublic void addResourceConnection(XMPPResourceConnection conn) throws TigaseStringprepException
conn
- XMPPResourceConnection
that is being added.TigaseStringprepException
public void incPacketsCounter()
public void removeResourceConnection(XMPPResourceConnection conn)
XMPPResourceConnection
user's resource connection
from the list of all active user connections within given XMPPSession
and detaches XMPPSession
from the removed XMPPResourceConnection
conn
- public void streamClosed(XMPPResourceConnection conn)
XMPPResourceConnection
conn
- - XMPPResourceConnection
for which stream was closed.public List<XMPPResourceConnection> getActiveResources()
XMPPResourceConnection
objects related
to this XMPPSession
objectpublic List<XMPPResourceConnection> getActiveResourcesClone()
XMPPResourceConnection
objects
related to this XMPPSession
objectpublic int getActiveResourcesSize()
XMPPResourceConnection
objects
related to this XMPPSession
objectpublic Object getCommonSessionData(String key)
key
which is common to all resource
connections within this XMPPSession
related to this XMPPSession
objectkey
- for which data should be returnedpublic JID[] getConnectionIds()
XMPPSession
public JID[] getJIDs()
XMPPSession
public long getLiveTime()
public long getPacketsCounter()
public XMPPResourceConnection getResourceConnection(JID jid)
XMPPResourceConnection
for particular FullJID. In
case there are no sessions null
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.jid
- FullJID for which a XMPPResourceConnection
should be
returnedpublic XMPPResourceConnection getResourceForConnectionId(JID connectionId)
XMPPResourceConnection
for particular ConnectionID.
In case there is no session that match given ConnectionID then null
is returned.connectionId
- ConnectionID for which XMPPResourceConnection
should be
returnedpublic XMPPResourceConnection getResourceForJID(JID jid)
XMPPResourceConnection
for particular FullJID (using
resource
name as determinant. In case there is no session that
match - null
is returned.jid
- FullJID for which a XMPPResourceConnection
should be
returnedpublic XMPPResourceConnection getResourceForResource(String resource)
XMPPResourceConnection
for particular
resource
. In case there is no session that match - null
is
returned.resource
- resource string for which a XMPPResourceConnection
should be
returnedpublic String getUserName()
XMPPSession
(i.e.
mostly localpart of JID)protected Object computeCommonSessionDataIfAbsent(String key, java.util.function.Function<String,Object> valueFactory)
protected void putCommonSessionData(String key, Object value)
key
- under which data should be storevalue
- data to be storedprotected Object putCommonSessionDataIfAbsent(String key, Object value)
Copyright © 2018 "Tigase, Inc.". All rights reserved.