Package tigase.xmpp

Class XMPPSession

java.lang.Object
tigase.xmpp.XMPPSession

public class XMPPSession extends Object
XMPPSession class is a container class for all XMPPResourceConnection objects for particular user (i.e. all user's connected resources)
  • Constructor Details

    • XMPPSession

      public XMPPSession(String username)
      Creates a new XMPPSession instance.
      Parameters:
      username - - localpart of user's JID
  • Method Details

    • 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 particular XMPPResourceConnection user's resource connection from the list of all active user connections within given XMPPSession and detaches XMPPSession from the removed XMPPResourceConnection
    • streamClosed

      public void streamClosed(XMPPResourceConnection conn)
      Method is called upon closing stream connection and removes particular XMPPResourceConnection
      Parameters:
      conn - - XMPPResourceConnection for which stream was closed.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getActiveResources

      public List<XMPPResourceConnection> getActiveResources()
      Method returns a List of all XMPPResourceConnection objects related to this XMPPSession object
    • getActiveResourcesClone

      public List<XMPPResourceConnection> getActiveResourcesClone()
      Method returns a cloned List of all XMPPResourceConnection objects related to this XMPPSession object
    • getActiveResourcesSize

      public int getActiveResourcesSize()
      Method returns number of all XMPPResourceConnection objects related to this XMPPSession object
    • getCommonSessionData

      public 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
      Parameters:
      key - for which data should be returned
    • getConnectionIds

      public JID[] getConnectionIds()
      Method returns an array of all ConnectionIDs related to this XMPPSession
    • getJIDs

      public JID[] getJIDs()
      Method returns an array of all FullJIDs related to this XMPPSession
    • 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 returns 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.
      Parameters:
      jid - FullJID for which a XMPPResourceConnection should be returned
    • getResourceForConnectionId

      public XMPPResourceConnection getResourceForConnectionId(JID connectionId)
      Method returns XMPPResourceConnection for particular ConnectionID. In case there is no session that match given ConnectionID then null is returned.
      Parameters:
      connectionId - ConnectionID for which XMPPResourceConnection should be returned
    • getResourceForJID

      public XMPPResourceConnection getResourceForJID(JID jid)
      Method returns XMPPResourceConnection for particular FullJID (using resource name as determinant. In case there is no session that match - null is returned.
      Parameters:
      jid - FullJID for which a XMPPResourceConnection should be returned
    • getResourceForResource

      public XMPPResourceConnection getResourceForResource(String resource)
      Method returns XMPPResourceConnection for particular resource. In case there is no session that match - null is returned.
      Parameters:
      resource - resource string for which a XMPPResourceConnection should be returned
    • getUserName

      public String getUserName()
      Method returns username that is related to this XMPPSession (i.e. mostly localpart of JID)
    • computeCommonSessionDataIfAbsent

      public Object computeCommonSessionDataIfAbsent(String key, Function<String,Object> valueFactory)
    • putCommonSessionData

      protected void putCommonSessionData(String key, Object value)
      Method used to store data common for all connections of the user.
      Parameters:
      key - under which data should be store
      value - data to be stored
    • putCommonSessionDataIfAbsent

      protected Object putCommonSessionDataIfAbsent(String key, Object value)
    • removeCommonSessionData

      protected Object removeCommonSessionData(String key)
      Method used to remove data common for all connections of the user.
      Parameters:
      key - for which data should be removed