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 client
    void delayedClose​(int delayInMillisecs)
    Closes the session and disconnects the client after the specified delay
    void 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 to
    CompressibleData getGameUserData()
    Returns the game user data of the session user.
    Player getPlayer()
    Returns the player instance associated with this session
    Room getRoom()
    Returns the room joined by the session or null if no room has been joined
    String getSessionId()
    Returns the session ID - a unique identifier for each session
    User getUser()
    Returns the user instance associated with this session
    boolean hasJoinedRoom()
    REturns true if the session has joined a room
    boolean isIngame()
    returns true if session is taking part in a game being played in the room
    boolean isSeated()
    Returns true if the session is seated
    boolean isSpectator()
    Returns true if the session is a spectator - i.e.
    void joinRoom​(Room room)
    Makes the session join the specified room
    void leaveRoom()
    Evicts the session from the room that it has joined
    void 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 delay
    void sendDelayedMessage​(String command, String data, int delayInMillisecs)
    Sends a message to the session's client after the specified delay
    void sendDelayedMessage​(String command, JsonObject data, int delayInMillisecs)
    Sends a message to the session's client after the specified delay
    void sendMessage​(String command, byte[] data)
    Sends a message to the session's client
    void sendMessage​(String command, String data)
    Sends a message to the session's client
    void sendMessage​(String command, JsonObject data)
    Sends a message to the session's client
    void sendUserData()
    Sends the session user's data to the session's client
    void takeSeat​(int seatNo, JsonObject takeSeatData)
    Makes the session take the specified seat

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getSessionId

      public String getSessionId()
      Returns the session ID - a unique identifier for each session
      Returns:
      String - the session ID
    • getGameName

      public String 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

      public CompressibleData 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

      public final void joinRoom​(Room room)
      Makes the session join the specified room
      Parameters:
      room - - the room to join
    • takeSeat

      public final void takeSeat​(int seatNo, JsonObject takeSeatData)
      Makes the session take the specified seat
      Parameters:
      seatNo - - the seat number to sit on
      takeSeatData - - 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

      public final void sendMessage​(String command, JsonObject data)
      Sends a message to the session's client
      Parameters:
      command - - the message command
      data - - the message data as JsonUtil
    • sendMessage

      public final void sendMessage​(String command, String data)
      Sends a message to the session's client
      Parameters:
      command - - the message command
      data - - the message data as a String
    • sendMessage

      public final void sendMessage​(String command, byte[] data)
      Sends a message to the session's client
      Parameters:
      command - - the message command
      data - - the message data as a byte array
    • sendUserData

      public final void sendUserData()
      Sends the session user's data to the session's client
    • sendDelayedMessage

      public final void sendDelayedMessage​(String command, JsonObject data, int delayInMillisecs)
      Sends a message to the session's client after the specified delay
      Parameters:
      command - - the message command
      data - - the message data as JsonUtil
      delayInMillisecs - - the delay in milliseconds
    • sendDelayedMessage

      public final void sendDelayedMessage​(String command, String data, int delayInMillisecs)
      Sends a message to the session's client after the specified delay
      Parameters:
      command - - the message command
      data - - the message data as a String
      delayInMillisecs - - the delay in milliseconds
    • sendDelayedMessage

      public final void sendDelayedMessage​(String command, byte[] data, int delayInMillisecs)
      Sends a message to the session's client after the specified delay
      Parameters:
      command - - the message command
      data - - the message data as a byte array
      delayInMillisecs - - the delay in milliseconds
    • getRoom

      public final Room 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

      public Player getPlayer()
      Returns the player instance associated with this session
      Returns:
      Player - the player instance associated with this session
    • getUser

      public final User getUser()
      Returns the user instance associated with this session
      Returns:
      User - the user instance associated with this session