Package io.sockit.gameserver
Class Session
java.lang.Object
io.sockit.gameserver.Session
public class Session extends Object
Represents a client session - i.e. a client connected to the server.
-
Method Summary
Modifier and Type Method Description void
close()
Closes the session and disconnects the clientvoid
delayedClose(int delayInMillisecs)
Closes the session and disconnects the client after the specified delayvoid
gameDataModified()
Marks the session user's game data as modified so that the changes will get saved to the game database.String
getGameName()
Returns the name of the game to which this session is linked toCompressibleData
getGameUserData()
Returns the game user data of the session user.Player
getPlayer()
Returns the player instance associated with this sessionRoom
getRoom()
Returns the room joined by the session or null if no room has been joinedString
getSessionId()
Returns the session ID - a unique identifier for each sessionUser
getUser()
Returns the user instance associated with this sessionboolean
hasJoinedRoom()
REturns true if the session has joined a roomboolean
isIngame()
returns true if session is taking part in a game being played in the roomboolean
isSeated()
Returns true if the session is seatedboolean
isSpectator()
Returns true if the session is a spectator - i.e.void
joinRoom(Room room)
Makes the session join the specified roomvoid
leaveRoom()
Evicts the session from the room that it has joinedvoid
leaveSeat()
Evicts the session from its seat.void
sendDelayedMessage(String command, byte[] data, int delayInMillisecs)
Sends a message to the session's client after the specified delayvoid
sendDelayedMessage(String command, String data, int delayInMillisecs)
Sends a message to the session's client after the specified delayvoid
sendDelayedMessage(String command, JsonObject data, int delayInMillisecs)
Sends a message to the session's client after the specified delayvoid
sendMessage(String command, byte[] data)
Sends a message to the session's clientvoid
sendMessage(String command, String data)
Sends a message to the session's clientvoid
sendMessage(String command, JsonObject data)
Sends a message to the session's clientvoid
sendUserData()
Sends the session user's data to the session's clientvoid
takeSeat(int seatNo, JsonObject takeSeatData)
Makes the session take the specified seat
-
Method Details
-
getSessionId
Returns the session ID - a unique identifier for each session- Returns:
- String - the session ID
-
getGameName
Returns the name of the game to which this session is linked to- Returns:
- String - the name of the game to which this session is linked to
-
gameDataModified
public final void gameDataModified()Marks the session user's game data as modified so that the changes will get saved to the game database. The game user data is the additional game data saved for each user such as chipsInHand -
getGameUserData
Returns the game user data of the session user. The game user data is the additional game data saved for each user such as chipsInHand- Returns:
- GameUserData - the game user data of the session's user
-
leaveRoom
public final void leaveRoom()Evicts the session from the room that it has joined -
close
public final void close()Closes the session and disconnects the client -
joinRoom
Makes the session join the specified room- Parameters:
room
- - the room to join
-
takeSeat
Makes the session take the specified seat- Parameters:
seatNo
- - the seat number to sit ontakeSeatData
- - the additional data required to take seat as JsonUtil. for example in poker this could the chips to put on table
-
leaveSeat
public final void leaveSeat()Evicts the session from its seat. -
delayedClose
public final void delayedClose(int delayInMillisecs)Closes the session and disconnects the client after the specified delay- Parameters:
delayInMillisecs
- - the delay in milliseconds
-
sendMessage
Sends a message to the session's client- Parameters:
command
- - the message commanddata
- - the message data as JsonUtil
-
sendMessage
Sends a message to the session's client- Parameters:
command
- - the message commanddata
- - the message data as a String
-
sendMessage
Sends a message to the session's client- Parameters:
command
- - the message commanddata
- - the message data as a byte array
-
sendUserData
public final void sendUserData()Sends the session user's data to the session's client -
sendDelayedMessage
Sends a message to the session's client after the specified delay- Parameters:
command
- - the message commanddata
- - the message data as JsonUtildelayInMillisecs
- - the delay in milliseconds
-
sendDelayedMessage
Sends a message to the session's client after the specified delay- Parameters:
command
- - the message commanddata
- - the message data as a StringdelayInMillisecs
- - the delay in milliseconds
-
sendDelayedMessage
Sends a message to the session's client after the specified delay- Parameters:
command
- - the message commanddata
- - the message data as a byte arraydelayInMillisecs
- - the delay in milliseconds
-
getRoom
Returns the room joined by the session or null if no room has been joined- Returns:
- Room - the room joined by the session
-
hasJoinedRoom
public boolean hasJoinedRoom()REturns true if the session has joined a room- Returns:
- boolean - true if the session has joined a room
-
isSpectator
public final boolean isSpectator()Returns true if the session is a spectator - i.e. has joined a room and is not seated- Returns:
- boolean - true if session is a spectator
-
isSeated
public boolean isSeated()Returns true if the session is seated- Returns:
- boolean - true if the session is seated
-
isIngame
public boolean isIngame()returns true if session is taking part in a game being played in the room- Returns:
- boolean - true if session is taking part in a game being played in the room
-
getPlayer
Returns the player instance associated with this session- Returns:
- Player - the player instance associated with this session
-
getUser
Returns the user instance associated with this session- Returns:
- User - the user instance associated with this session
-