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 Summary
Modifier and TypeMethodDescriptionvoidaddReadBytes(long amount) voidaddTcpDroppedPackets(int amount) voidaddUdpDroppedPackets(int amount) voidaddWrittenBytes(long amount) voidclose()booleancontainsProperty(String name) booleancontainsSystemProperty(String name) voiddestroy()voidfreeze()Get the session IP addressintGet the client side TCP port numberlongThe Session's creation time as Unix Time in milliseconds.com.smartfoxserver.bitswarm.sessions.IPacketQueuelongGet the IPAddress and Port of the user as a String in the format "1.2.3.4:1234"Get the full server address and port to which the user connected to, in the form "1.2.3.4:1234"A unique string token that identifies the SessionintgetId()Get the unique session Idcom.smartfoxserver.bitswarm.sessions.ISeqProcessorlongThe last time that the client Session has sent a packet (milliseconds Unix Time)longThe last time that the Session has sent a Request (milliseconds Unix Time)longlongintGet the maximum time of socket inactivity after which the system will consider the Session "idle" and disconnect itintGet the maximum time of User inactivity after which the system will consider the session "idle" and disconnect itintGet the maximum idle time for User's UDP connection before it is considered disconnectedcom.smartfoxserver.bitswarm.sessions.IPacketQueuegetProperty(String key) Get a custom property from the SessionlongThe amount of data in bytes that the client has sent so farintGet the interval of time allowed for a Session to attempt a reconnection after and abrupt loss of connection.Get the server address to which the user connected tointGet the server port to which the user connected tocom.smartfoxserver.bitswarm.sessions.ISessionManagergetSystemProperty(String key) longgetType()Get the Session typecom.smartfoxserver.bitswarm.data.UDPConnectionlonglongThe amount of data that was sent to the client so farvoidbooleanvoidhandshakeComplete(boolean value) booleanCheck if the session is connected.booleanbooleanisFrozen()booleanisIdle()booleanCheck if the the Session is logged in.booleanbooleanbooleanbooleanvoidremoveProperty(String key) Remove an asoociated propertyvoidvoidsetConnected(boolean value) voidsetConnection(SocketChannel connection) voidsetCreationTime(long timestamp) voidsetCryptoKey(Object key) voidsetDatagramOutQueue(com.smartfoxserver.bitswarm.sessions.IPacketQueue queue) voidvoidsetId(int id) voidsetInSeqProcessor(com.smartfoxserver.bitswarm.sessions.ISeqProcessor processor) voidsetLastActivityTime(long timestamp) voidsetLastLoggedInActivityTime(long timestamp) voidsetLastReadTime(long timestamp) voidsetLastWriteTime(long timestamp) voidsetLoggedIn(boolean value) voidvoidsetMaxIdleTime(int idleTime) voidsetMaxLoggedInIdleTime(int idleTime) voidsetMaxUdpIdleTime(int seconds) voidsetPacketOutQueue(com.smartfoxserver.bitswarm.sessions.IPacketQueue queue) voidsetProperty(String key, Object value) Can be used to attach custom properties to a Session at runtime.voidsetReconnectionSeconds(int value) voidsetSessionManager(com.smartfoxserver.bitswarm.sessions.ISessionManager manager) voidsetSystemProperty(String key, Object property) voidsetType(SessionType type) voidsetUdpConnection(com.smartfoxserver.bitswarm.data.UDPConnection conn) voidsetUdpKeepAlive(boolean value) voidunfreeze()
-
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
-
getType
SessionType getType()Get the Session type- Returns:
- the Session type
- See Also:
-
setType
-
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
- 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 itNOTE: 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 itNOTE: 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 disconnectedNOTE: 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
- Internal
-
getSystemProperty
- Internal
-
setSystemProperty
- Internal
-
removeSystemProperty
- Internal
-
containsProperty
- Internal
-
getProperty
Get a custom property from the Session- Parameters:
key- the property name- Returns:
- the associated value, null if no property exists
-
setProperty
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 propertyvalue- any Object
-
removeProperty
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
- 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
- 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
-