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 voidclose()Closes the session and disconnects the clientvoiddelayedClose(int delayInMillisecs)Closes the session and disconnects the client after the specified delayvoidgameDataModified()Marks the session user's game data as modified so that the changes will get saved to the game database.StringgetGameName()Returns the name of the game to which this session is linked toCompressibleDatagetGameUserData()Returns the game user data of the session user.PlayergetPlayer()Returns the player instance associated with this sessionRoomgetRoom()Returns the room joined by the session or null if no room has been joinedStringgetSessionId()Returns the session ID - a unique identifier for each sessionUsergetUser()Returns the user instance associated with this sessionbooleanhasJoinedRoom()REturns true if the session has joined a roombooleanisIngame()returns true if session is taking part in a game being played in the roombooleanisSeated()Returns true if the session is seatedbooleanisSpectator()Returns true if the session is a spectator - i.e.voidjoinRoom(Room room)Makes the session join the specified roomvoidleaveRoom()Evicts the session from the room that it has joinedvoidleaveSeat()Evicts the session from its seat.voidsendDelayedMessage(String command, byte[] data, int delayInMillisecs)Sends a message to the session's client after the specified delayvoidsendDelayedMessage(String command, String data, int delayInMillisecs)Sends a message to the session's client after the specified delayvoidsendDelayedMessage(String command, JsonObject data, int delayInMillisecs)Sends a message to the session's client after the specified delayvoidsendMessage(String command, byte[] data)Sends a message to the session's clientvoidsendMessage(String command, String data)Sends a message to the session's clientvoidsendMessage(String command, JsonObject data)Sends a message to the session's clientvoidsendUserData()Sends the session user's data to the session's clientvoidtakeSeat(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
-