Interface ISession

  • All Known Implementing Classes:
    Session

    public interface ISession
    • Method Detail

      • getId

        int getId()
        Get the unique session Id
        Returns:
        the unique session id
      • setId

        void setId​(int id)
      • getHashId

        java.lang.String getHashId()
        A unique string token used as an alternative session ID
        Returns:
        a unique string token used as an alternative session ID
      • setHashId

        void setHashId​(java.lang.String hash)
      • getNodeId

        java.lang.String getNodeId()
        Return the node Id in a cluster
        Returns:
        the node Id in a cluster
      • setNodeId

        void setNodeId​(java.lang.String nodeId)
      • isLocal

        boolean isLocal()
        See if the Session is local or hosted in another cluster node.
        Returns:
        true if the session is local.
      • isLoggedIn

        boolean isLoggedIn()
        Check if the the Session is logged in.
        Returns:
        true if the session has performed the login process
      • setLoggedIn

        void setLoggedIn​(boolean value)
      • getPacketQueue

        com.smartfoxserver.bitswarm.sessions.IPacketQueue getPacketQueue()
      • setPacketQueue

        void setPacketQueue​(com.smartfoxserver.bitswarm.sessions.IPacketQueue queue)
      • getConnection

        java.nio.channels.SocketChannel getConnection()
      • setConnection

        void setConnection​(java.nio.channels.SocketChannel connection)
      • getDatagramChannel

        java.nio.channels.DatagramChannel getDatagramChannel()
      • setDatagramChannel

        void setDatagramChannel​(java.nio.channels.DatagramChannel channel)
      • getCreationTime

        long getCreationTime()
        The timestamp at which the connection was done (milliseconds Unix Time)
        Returns:
        the timestamp at which the connection was done (milliseconds Unix Time)
      • setCreationTime

        void setCreationTime​(long timestamp)
      • isConnected

        boolean isConnected()
        Check if the session is connected.
        Returns:
        true if the session is connected.
      • setConnected

        void setConnected​(boolean value)
      • getLastActivityTime

        long getLastActivityTime()
        The last time that the session has sent a packet (milliseconds Unix Time)
        Returns:
        the last time that the session has sent a packet (milliseconds Unix Time)
      • setLastActivityTime

        void setLastActivityTime​(long timestamp)
      • getLastLoggedInActivityTime

        long getLastLoggedInActivityTime()
        The last time that the session has sent a request (milliseconds Unix Time)
        Returns:
        the last time that the session has sent a request (milliseconds Unix Time)
      • setLastLoggedInActivityTime

        void setLastLoggedInActivityTime​(long timestamp)
      • getLastReadTime

        long getLastReadTime()
      • setLastReadTime

        void setLastReadTime​(long timestamp)
      • getLastWriteTime

        long getLastWriteTime()
      • setLastWriteTime

        void setLastWriteTime​(long timestamp)
      • getReadBytes

        long getReadBytes()
        The amount of data in bytes that the client has sent so far
        Returns:
        the amount of data in bytes that the user has sent so far
      • addReadBytes

        void addReadBytes​(long amount)
      • getWrittenBytes

        long getWrittenBytes()
        The amount of data that was sent to the client so far
        Returns:
        the amount of data that was sent to the client so far
      • addWrittenBytes

        void addWrittenBytes​(long amount)
      • getDroppedMessages

        int getDroppedMessages()
        The number of messages that were dropped since the connection
        Returns:
        the number of messages that were dropped since the connection
      • addDroppedMessages

        void addDroppedMessages​(int amount)
      • getMaxIdleTime

        int getMaxIdleTime()
        Get the maximum time of socket inactivity after which the system will consider the User "idle" and disconnect it.

        NOTE: This is valid until the client is not logged in, then the maxLoggedInIdleTime will be used.

        Returns:
        get the maximum time of inactivity after which the system will consider the User "idle" and disconnect it
      • setMaxIdleTime

        void setMaxIdleTime​(int idleTime)
      • getMaxLoggedInIdleTime

        int getMaxLoggedInIdleTime()
        Get the maximum time of User inactivity after which the system will consider the session "idle" and disconnect it.

        NOTE: This applies only if the client is logged in.

        Returns:
        Get the maximum time of User inactivity after which the system will consider the session "idle" and disconnect it.
      • setMaxLoggedInIdleTime

        void setMaxLoggedInIdleTime​(int idleTime)
      • isMarkedForEviction

        boolean isMarkedForEviction()
      • setMarkedForEviction

        void setMarkedForEviction()
      • isIdle

        boolean isIdle()
      • isFrozen

        boolean isFrozen()
      • freeze

        void freeze()
      • unfreeze

        void unfreeze()
      • getFreezeTime

        long getFreezeTime()
      • isReconnectionTimeExpired

        boolean isReconnectionTimeExpired()
      • getSystemProperty

        java.lang.Object getSystemProperty​(java.lang.String key)
      • setSystemProperty

        void setSystemProperty​(java.lang.String key,
                               java.lang.Object property)
      • removeSystemProperty

        void removeSystemProperty​(java.lang.String key)
      • getProperty

        java.lang.Object getProperty​(java.lang.String key)
      • setProperty

        void setProperty​(java.lang.String key,
                         java.lang.Object property)
      • removeProperty

        void removeProperty​(java.lang.String key)
      • getFullIpAddress

        java.lang.String getFullIpAddress()
        Get the IPAddress and Port of the user as a String in the format "1.2.3.4:1234"
        Returns:
        the ip address and port of the client
      • getAddress

        java.lang.String getAddress()
        Get the session IP address
        Returns:
        the session IP address
      • getClientPort

        int getClientPort()
        Get the client side TCP port number
        Returns:
        get the client side TCP port number
      • getServerAddress

        java.lang.String getServerAddress()
        Get the server address to which the user connected to
        Returns:
        get the server address to which the user connected to
      • getServerPort

        int getServerPort()
        Get the server port to which the user connected to
        Returns:
        get the server port to which the user connected to
      • getFullServerIpAddress

        java.lang.String getFullServerIpAddress()
        Get the full server address and port to which the user connected to, in the form "1.2.3.4:1234"
        Returns:
        get the server address and port to which the user connected to
      • getSessionManager

        com.smartfoxserver.bitswarm.sessions.ISessionManager getSessionManager()
      • setSessionManager

        void setSessionManager​(com.smartfoxserver.bitswarm.sessions.ISessionManager manager)
      • close

        void close()
            throws java.io.IOException
        Throws:
        java.io.IOException
      • getReconnectionSeconds

        int getReconnectionSeconds()
        Get the interval of time allowed for a Session to attempt a reconnection after and abrupt loss of connection. Once the time has expired and reconnection was done the User will finally be disconnected from the system.
        Returns:
        the amount of seconds allowed for a reconnection.
      • setReconnectionSeconds

        void setReconnectionSeconds​(int value)
      • isEncrypted

        boolean isEncrypted()
      • getCryptoKey

        java.lang.Object getCryptoKey()
      • setCryptoKey

        void setCryptoKey​(java.lang.Object key)
      • isUdpEnabled

        boolean isUdpEnabled()