Interface ISession

All Known Implementing Classes:
Session

public interface ISession
A Session object is created every time a TCP/Websocket or HTTP connection to the server is made. The Session represents the client connection at the lower level. When a client performs a valid log in in one of the Server's Zones a User object is created and associated with the Session.
  • Method Details

    • getId

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

      void setId(int id)
    • getHashId

      String getHashId()
      A unique string token that identifies the Session
      Returns:
      the unique Session token
    • setHashId

      void setHashId(String hash)
    • getType

      SessionType getType()
      Get the Session type
      Returns:
      the Session type
      See Also:
    • setType

      void setType(SessionType type)
    • 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)
    • getPacketOutQueue

      com.smartfoxserver.bitswarm.sessions.IPacketQueue getPacketOutQueue()
      Internal
    • setPacketOutQueue

      void setPacketOutQueue(com.smartfoxserver.bitswarm.sessions.IPacketQueue queue)
      Internal
    • getDatagramOutQueue

      com.smartfoxserver.bitswarm.sessions.IPacketQueue getDatagramOutQueue()
      Internal
    • setDatagramOutQueue

      void setDatagramOutQueue(com.smartfoxserver.bitswarm.sessions.IPacketQueue queue)
      Internal
    • getConnection

      SocketChannel getConnection()
      Internal
    • setConnection

      void setConnection(SocketChannel connection)
      Internal
    • getUdpConnection

      com.smartfoxserver.bitswarm.data.UDPConnection getUdpConnection()
      Internal
    • setUdpConnection

      void setUdpConnection(com.smartfoxserver.bitswarm.data.UDPConnection conn)
      Internal
    • getCreationTime

      long getCreationTime()
      The Session's creation time as Unix Time in milliseconds.
      Returns:
      the creation time
    • setCreationTime

      void setCreationTime(long timestamp)
      Internal
    • isConnected

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

      void setConnected(boolean value)
      Internal
    • getLastActivityTime

      long getLastActivityTime()
      The last time that the client 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)
      Internal
    • 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)
      Internal
    • getLastReadTime

      long getLastReadTime()
      Internal
    • setLastReadTime

      void setLastReadTime(long timestamp)
      Internal
    • getLastWriteTime

      long getLastWriteTime()
      Internal
    • setLastWriteTime

      void setLastWriteTime(long timestamp)
      Internal
    • 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)
      Internal
    • 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)
      Internal
    • getTcpDroppedPackets

      long getTcpDroppedPackets()
      Internal
    • addTcpDroppedPackets

      void addTcpDroppedPackets(int amount)
      Internal
    • getUdpDroppedPackets

      long getUdpDroppedPackets()
      Internal
    • addUdpDroppedPackets

      void addUdpDroppedPackets(int amount)
      Internal
    • getMaxIdleTime

      int getMaxIdleTime()
      Get the maximum time of socket inactivity after which the system will consider the Session "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 Session "idle" and disconnect it
    • setMaxIdleTime

      void setMaxIdleTime(int idleTime)
      Internal
    • 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)
      Internal
    • getMaxUdpIdleTime

      int getMaxUdpIdleTime()
      Get the maximum idle time for User's UDP connection before it is considered disconnected

      NOTE: This applies only if the client has an active UDP connection

      Returns:
      the max number of idle seconds
    • setMaxUdpIdleTime

      void setMaxUdpIdleTime(int seconds)
      Internal
    • isUdpKeepAlive

      boolean isUdpKeepAlive()
      Internal
    • setUdpKeepAlive

      void setUdpKeepAlive(boolean value)
    • isMarkedForEviction

      boolean isMarkedForEviction()
      Internal
    • setMarkedForEviction

      void setMarkedForEviction()
      Internal
    • isIdle

      boolean isIdle()
      Internal
    • isFrozen

      boolean isFrozen()
      Internal
    • freeze

      void freeze()
      Internal
    • unfreeze

      void unfreeze()
      Internal
    • getFreezeTime

      long getFreezeTime()
      Internal
    • isReconnectionTimeExpired

      boolean isReconnectionTimeExpired()
      Internal
    • containsSystemProperty

      boolean containsSystemProperty(String name)
      Internal
    • getSystemProperty

      Object getSystemProperty(String key)
      Internal
    • setSystemProperty

      void setSystemProperty(String key, Object property)
      Internal
    • removeSystemProperty

      void removeSystemProperty(String key)
      Internal
    • containsProperty

      boolean containsProperty(String name)
      Internal
    • getProperty

      Object getProperty(String key)
      Get a custom property from the Session
      Parameters:
      key - the property name
      Returns:
      the associated value, null if no property exists
    • setProperty

      void setProperty(String key, Object value)
      Can be used to attach custom properties to a Session at runtime. A common use case is to associate a number of properties before the User is logged in, when the User object isn't available yet.
      Parameters:
      key - name of the property
      value - any Object
    • removeProperty

      void removeProperty(String key)
      Remove an asoociated property
      Parameters:
      key - name of the property
    • getFullIpAddress

      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

      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

      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

      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()
      Internal
    • setSessionManager

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

      void close() throws IOException
      Throws:
      IOException
      Internal
    • 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)
      Internal
    • isEncrypted

      boolean isEncrypted()
      Internal
    • handshakeComplete

      boolean handshakeComplete()
      Internal
    • handshakeComplete

      void handshakeComplete(boolean value)
      Internal
    • getCryptoKey

      Object getCryptoKey()
      Internal
    • setCryptoKey

      void setCryptoKey(Object key)
      Internal
    • isUdpConnected

      boolean isUdpConnected()
      Internal
    • handleRDPDisconnection

      void handleRDPDisconnection()
      Internal
    • getInSeqProcessor

      com.smartfoxserver.bitswarm.sessions.ISeqProcessor getInSeqProcessor()
      Internal
    • setInSeqProcessor

      void setInSeqProcessor(com.smartfoxserver.bitswarm.sessions.ISeqProcessor processor)
    • destroy

      void destroy()
      Internal