Class Room

java.lang.Object
io.sockit.gameserver.Room
All Implemented Interfaces:
Comparable<Room>

public abstract class Room
extends Object
implements Comparable<Room>
This class is the super class for all Game Rooms. It has methods to start gamePlay, iterate players, etc. The seats in the room are like a rounded queue such that the next seat after the last seat will be the first seat. The Game developer should extend this class and override the various event/callback methods such as onRoomJoined(), onSeatTaken(), beforeGameStarted(), etc. to provide the game logic. See example below
 
    public class TicTacToeRoom  extends Room{
        
        CellState[] grid;
        
        public TicTacToeRoom(Game game, String roomName, RoomType roomType, int turnDurationInSecs, int delayAfterGameEnded, boolean enableDebug) {
                super(game, roomName, roomType, 2, turnDurationInSecs, delayAfterGameEnded, enableDebug);
                grid = new CellState[9];
                Arrays.fill(grid, CellState.unmarked);
        }

        {@literal @}Override
        protected Player newPlayer(Session session, int seatNo, JsonObject jo) {
                return new TicTacToePlayer(session, seatNo);
        }

        {@literal @}Override
        protected void resetData() {
                Arrays.fill(grid, CellState.unmarked);                
        }

        {@literal @}Override
        protected JsonObject prepareJsonForClient() {
                JsonObjectBuilder json =Json.createObjectBuilder();
                JsonArrayBuilder jsonGrid = Json.createArrayBuilder();
                for(int counter=0; counter < grid.length; counter++){
                        jsonGrid.add(grid[counter].toString());
                }
                json.add("grid", jsonGrid);
                
                return json.build();
        }

        {@literal @}Override
        protected void onPlayerAction(Player player, String action, JsonObject data, boolean isOutOfTurn) { 
                if(isOutOfTurn){
                        return;
                }
                if(action.equals("cellClicked")){
                        int cellIndex = data.getInt("cellIndex");

                        if(cellIndex > 8 || cellIndex < 0){
                                this.invalidateAction("Cell Dosen't exist", null);
                                return;
                        }

                        JsonObjectBuilder sendData = Json.createObjectBuilder();

                        if(grid[cellIndex] != CellState.unmarked){
                                sendData.add("cellIndex", cellIndex);
                                sendData.add("cellValue", grid[cellIndex].toString());
                                this.invalidateAction("Can't Click That!", sendData.build());
                                return;

                        }

                        TicTacToePlayer ticTacToePlayer = (TicTacToePlayer) player;
                        grid[cellIndex] = ticTacToePlayer.playerToken;

                        sendData.add("cellIndex", cellIndex);
                        sendData.add("cellValue", grid[cellIndex].toString());
                        this.actionPlayed("cellIndex", sendData.build());
                }
            }
        //.......
    }
 
 
  • Field Details

    • roomId

      public final Long roomId
      the room ID.
    • roomName

      public final String roomName
      the room name.
    • roomType

      public RoomType roomType
      the room type.
    • game

      public final Game game
      The Game to which this room belongs
    • minNoOfPlayersForGame

      public final int minNoOfPlayersForGame
      the min number of players required to start a new game. Once the min number of players take seat a new game automatically starts
    • debugEnabled

      public final boolean debugEnabled
      whether logging of debug messages is enabled for this player or not
  • Constructor Details

    • Room

      protected Room​(Game game, String roomName, RoomType roomType, int totalNoOfSeats, int turnDurationInSecs, int delayAfterGameEndedInSecs)
      Creates a room.
      Parameters:
      game - - the Game to which the room belongs
      roomName - - the room name
      roomType - - the room type
      totalNoOfSeats - - the max number of players (total number of seats in the room)
      turnDurationInSecs - - the duration of 1 turn in seconds
      delayAfterGameEndedInSecs - - the delay between end game and start of a new game.
    • Room

      protected Room​(Game game, String roomName, RoomType roomType, int totalNoOfSeats, int turnDurationInSecs, int delayAfterGameEndedInSecs, boolean enableDebug)
      Creates a room
      Parameters:
      game - - the Game to which the room belongs
      roomName - - the room name
      roomType - - the room type
      totalNoOfSeats - - the max number of players (total number of seats in the room)
      turnDurationInSecs - - the duration of 1 turn in seconds
      delayAfterGameEndedInSecs - - the delay between end game and start of a new game.
      enableDebug - - whether logging of debug messages should be enabled or not for this room
    • Room

      protected Room​(Game game, String roomName, RoomType roomType, int totalNoOfSeats, int turnDurationInSecs, int delayAfterGameEndedInSecs, boolean enableDebug, int minNoOfPlayersForGame)
      Parameters:
      game - - the Game to which the room belongs
      roomName - - the room name
      roomType - - the room type
      totalNoOfSeats - - the max number of players (total number of seats in the room)
      turnDurationInSecs - - the duration of 1 turn in seconds
      delayAfterGameEndedInSecs - - the delay between end game and start of a new game.
      enableDebug - - whether logging of debug messages should be enabled or not for this room
      minNoOfPlayersForGame - - the min number of players required to start a new game. Once the min number of players take seat a new game automatically starts
  • Method Details

    • compareTo

      public int compareTo​(Room room)
      Compares this object with the specified object for order. Called to sort the rooms in the location. This method should be overridden in the child class
      Specified by:
      compareTo in interface Comparable<Room>
      Parameters:
      room - - the room to compare to
      Returns:
      int - a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • newPlayer

      protected abstract Player newPlayer​(Session session, int SeatNo, JsonObject data)
      Factory method called to instantiate a new player. When a client session takes seat in the room, this method is called to create a player. Note: till the client session is not seated, the session is considered a spectator. After seat is taken the session is considered a player
      Parameters:
      session - - the client session of the player
      SeatNo - - the seat number of the player
      data - - any additional actionData required to initialize the player in json format
      Returns:
      - a new player object linked to the specified session
    • getTotalNoOfSeats

      public final int getTotalNoOfSeats()
      Returns the maximum number of players who can play in the room (total number of seats in the room)
      Returns:
      int - total number of seats in the room
    • getOwnerUserId

      public final String getOwnerUserId()
      Returns user Id of this room's owner if this room is private else null
      Returns:
      String - user Id of this room's owner if this room is private else null
    • isPrivate

      public final boolean isPrivate()
      Returns whether room is private or not
      Returns:
      boolean - true if the room is private
    • getDelayBeforeFirstTurnInSecs

      public int getDelayBeforeFirstTurnInSecs()
      Returns the delay between game start and first turn in seconds.
      Returns:
      int - the delayBeforeFirstTurn
    • getDelayAfterGamePlayEndedInSecs

      public int getDelayAfterGamePlayEndedInSecs()
      Returns the delay between end game play and start game play in seconds.
      Returns:
      int - the delayAfterGameEnded
    • setDelayBeforeFirstTurnInSecs

      public void setDelayBeforeFirstTurnInSecs​(int delayInSecs)
      Sets the delay between game play start and first turn in seconds.
      Parameters:
      delayInSecs - - the delay between game play start and first turn in seconds
    • getCurrentGamePlayNo

      public int getCurrentGamePlayNo()
      Returns the number of the currently active game play in the room. When a new game play starts, the gamePlay number is incremented by 1. The game number of the first game play is 1. This value is mainly for debugging purposes to identify which game play number the debug message belongs to
      Returns:
      int - the game play number of the currently active game play in the room.
    • sendRoomDataToAll

      public void sendRoomDataToAll()
      Sends Room Data to all the client sessions who have joined the room (both spectators and players)
    • sendRoomDataToSession

      public void sendRoomDataToSession​(Session session)
      Sends Room Data to the specified session
      Parameters:
      session - - the session to which the room actionData should be sent
    • sendRoomDataToSession

      public void sendRoomDataToSession​(Player player)
      Sends Room Data to the specified player's client session
      Parameters:
      player - - the player to whose client the room actionData should be sent
    • cancelAutoStartGamePlay

      public final void cancelAutoStartGamePlay()
      Prevents new game play from auto starting after a Game play ends. Should be called in afterGamePlayEnded() event to prevent a new game play from starting
    • startGamePlay

      public final void startGamePlay()
      Starts a new game play in the room if no game play is running. If a game play is already running in the room then nothing is done.
    • cancelStartGamePlay

      public final void cancelStartGamePlay()
      Cancels new Game play before first turn. Should be called in the beforeGameStarted event to cancel the new Game play.
    • gameAction

      public void gameAction​(String action, JsonObject data)
      Creates and sends a gameAction event/message to all the client's (client sessions - both spectators and players) connected to this room. for eg. in poker this method can be called when the flop, turn and river card/s is dealt
      Parameters:
      action - - the action
      data - - the actionData of the action in json format. For example in poker if the action is 'flop', the actionData will be the value of the flop cards
    • actionPlayed

      public final void actionPlayed​(String playerAction, JsonObject actionData)
      Sends turnPlayed or outOfTurnPlayed event/message to clients. Should be called in onPlayerAction() event after the player's action has been successfully processed
      Parameters:
      playerAction - - the player's processed action. for example in poker it could be 'folded' or 'raised'. Cannot be null. Can be empty String
      actionData - - the action data in json. for eg data could be {"amtBet":48,"raisedBy":20}
      Throws:
      NullPointerException - - if playerAction is null
    • setErrorDescription

      public void setErrorDescription​(String errorDescription)
      Sets the error description to be sent to client. For example in canSeatBeTaken() if chips are too less to take seat you can set the error description to 'Chips too less to take seat. Min chips required 100'
      Parameters:
      errorDescription - - the error description
    • invalidateAction

      public void invalidateAction​(String errorDescription, JsonObject errorData)
      Sets the errorDescription and errorData that is sent to client when the action is not valid. Call this method in onPlayerAction() event to invalidate the action. For example in poker if the amt bet is too less, you can invalidate the action with an error description of 'Bet value too less.' and errorData as {"minBet":50,"actualBet":20}
      Parameters:
      errorDescription - - the error description
      errorData - - the error data
    • forceAction

      public final void forceAction​(Player player, String action, JsonObject actionData)
      Forces an action on the specified player. Usually called in turnTimedOut() event to play a default action on a player whose turn has timed out. For example in poker you can call this method in onTurnTimedOut() event to force the default action of 'check' or 'fold' on the player.
      Parameters:
      player - - the player on whom to force the action
      action - - the action to be forced
      actionData - - the action data
    • isGamePlayEnding

      public final boolean isGamePlayEnding()
      Checks whether Game play is ending or not. For example in poker this method can be called in Player.getGameDataToJsonForOthers() method to decide if a player's hole cards should be sent to other clients or not because on GameEnd your cards are visible to all players
      Returns:
      boolean - true is Game is ending
    • endGamePlay

      public final void endGamePlay()
      Ends the currently running game play in the room
    • resetData

      protected abstract void resetData()
      Called after End Game play to reset game play data. This method should be overridden in the child class
    • leaveSeat

      public final void leaveSeat​(Session session)
      Evicts the specified client session from his/her seat
      Parameters:
      session - - the client session to be evicted
    • leaveSeat

      public final void leaveSeat​(Player player)
      Evicts the specified player from his/her seat. This method is similar to leaveSeat(Session session)
      Parameters:
      player - - the player to be evicted
    • leave

      public final void leave​(Session session)
      Evicts the specified client session from the room.
      Parameters:
      session - - the client session to be evicted
    • isGamePlayInProgress

      public final boolean isGamePlayInProgress()
      Returns whther a game play is in progress or not in the room
      Returns:
      boolean - true is a game play is in progress
    • getSpectators

      public final Iterable<Session> getSpectators()
      returns all the client session who are spectators
      Returns:
      Iterable<Session> - the spectators as an iterable
    • getPlayersWhoPlayed

      public final Iterable<Player> getPlayersWhoPlayed()
      Returns all the players who took part in the current game play.
      Returns:
      Iterable<Player> - the players who took part in the current game play
    • isSeated

      public final boolean isSeated​(Session session)
      Returns whether the specified client session is seated or not
      Parameters:
      session - - the client session
      Returns:
      boolean - true if the specified client session is seated
    • isSpectator

      public final boolean isSpectator​(Session session)
      returns whether specified client session is a spectator or not. A spectator is a client session which is not seated
      Parameters:
      session - - the client session
      Returns:
      boolean - true if the specified session is a spectator
    • totalNoOfSeats

      public final int totalNoOfSeats()
      the total number of seats in the room
      Returns:
      int - total number of seats
    • playerCount

      public final int playerCount()
      the number of players in the room ( the number of session seated in the room)
      Returns:
      int - number of players
    • activePlayerCount

      public final int activePlayerCount()
      The number of players active (i.e. playing) in the current game play. (i.e number of players who have not exited the game play)
      Returns:
      int - number of players active in the current game play
    • nonBotPlayerCount

      public final int nonBotPlayerCount()
      The number of non bot players in the room. (the number of non bot sessions seated in the room)
      Returns:
      int - The number of non bot players in the room
    • activeNonBotPlayerCount

      public final int activeNonBotPlayerCount()
      The number of non bot players active in the current game play. (i.e number of non bot players who have not exited the game play)
      Returns:
      int - number of non bot players active in the current game play
    • botPlayerCount

      public final int botPlayerCount()
      The number of bot players in the room. (the number of bot sessions seated in the room)
      Returns:
      int - The number of bot players in the room
    • activeBotPlayerCount

      public final int activeBotPlayerCount()
      The number of bot players active in the current game play - (i.e number of bot players who have not exited the game play)
      Returns:
      int - number of bot players in the current game
    • spectatorCount

      public final int spectatorCount()
      The number of spectators (sessions not seated)
      Returns:
      int - the number of spectators
    • getLocation

      public final Location getLocation()
      Returns the room's location
      Returns:
      Location - the room's location
    • getTurnDurationInSecs

      public final int getTurnDurationInSecs()
      Returns the turn duration in seconds
      Returns:
      int - the turn duration in seconds
    • destroy

      public final void destroy()
      Destroys the room.
    • sendJsonMessageToAll

      public final void sendJsonMessageToAll​(String command, JsonObject data, Session sessionNotToSend)
      Sends a Json message to all sessions in the room except the one specified.
      Parameters:
      command - - the message command
      data - - the message data as json
      sessionNotToSend - - the session to which message should not be sent. Can be null.
    • sendJsonMessageToSpectators

      public final void sendJsonMessageToSpectators​(String command, JsonObject data, Session sessionNotToSend)
      Sends a Json message to all spectators in the room except the one specified.
      Parameters:
      command - - the message command
      data - - the message data as json
      sessionNotToSend - - the session to which message should not be sent. Can be null.
    • sendJsonMessageToPlayers

      public final void sendJsonMessageToPlayers​(String command, JsonObject data, Session sessionNotToSend)
      Sends a Json message to all players in the room except the one specified.
      Parameters:
      command - - the message command
      data - - the message data as json
      sessionNotToSend - - the session to which message should not be sent. Can be null.
    • sendTxtMessageToAll

      public final void sendTxtMessageToAll​(String command, String data, Session sessionNotToSend)
      Sends a text message to all sessions in the room except the one specified.
      Parameters:
      command - - the message command
      data - - the message data/text
      sessionNotToSend - - the session to which message should not be sent. Can be null.
    • sendTxtMessageToSpectators

      public final void sendTxtMessageToSpectators​(String command, String data, Session sessionNotToSend)
      Sends a text message to all spectators in the room except the one specified.
      Parameters:
      command - - the message command
      data - - the message data/text
      sessionNotToSend - - the session to which message should not be sent. Can be null.
    • sendTxtMessageToPlayers

      public final void sendTxtMessageToPlayers​(String command, String data, Session sessionNotToSend)
      Sends a text message to all players in the room except the one specified.
      Parameters:
      command - - the message command
      data - - the message data/text
      sessionNotToSend - - the session to which message should not be sent. Can be null.
    • getPlayers

      public final Iterable<Player> getPlayers()
      Returns all the players in the room
      Returns:
      Iterable@lt;Player> - all the players in the room
    • getActivePlayers

      public final Iterable<Player> getActivePlayers()
      Returns all the players active in the current game play
      Returns:
      Iterable@lt;Player> - all the players active in the current game play
    • getNextActivePlayer

      public final Player getNextActivePlayer()
      returns the next active player seated after the current turn player.
      Returns:
      Player - the first active player after the current turn player
    • getNextActivePlayer

      public final Player getNextActivePlayer​(int prevSeatNo)
      returns the next active player seated after the specified seat number.
      Parameters:
      prevSeatNo - - the seat number after which to start searching
      Returns:
      Player - the first active player after the specified seat number
    • getFirstActivePlayer

      public final Player getFirstActivePlayer()
      Returns the first active player
      Returns:
      Player - the first active player
    • getFirstPlayer

      public final Player getFirstPlayer()
      Returns the first player in the room
      Returns:
      Player - the first player in the room
    • getNextPlayer

      public final Player getNextPlayer​(int prevSeatNo)
      Returns the next player seated after the specified seat number
      Parameters:
      prevSeatNo - - the previous seat number
      Returns:
      Player - the next player seated after the specified seat number
    • getNextActivePlayerWhoCanPlayTurn

      public final Player getNextActivePlayerWhoCanPlayTurn()
      Returns the next active player after the current player who can play a turn (player.canPlayTurn() returns true). For example in poker if a player is allIn then he/she cannot play another turn in the game.
      Returns:
      Player - the next active player who can play a turn
    • getNextActivePlayerWhoCanPlayTurn

      public final Player getNextActivePlayerWhoCanPlayTurn​(int prevSeatNo)
      Returns the next active player after the specified seat number who can play a turn (player.canPlayTurn() returns true). For example in poker if a player is allIn then he/she cannot play another turn in the game.
      Parameters:
      prevSeatNo - - the previous seat number
      Returns:
      Player - the next turn player after the specified seat number who can play a turn
    • getPlayerBySeatNo

      public final Player getPlayerBySeatNo​(int seatNo)
      Returns player seated at the specified seat number
      Parameters:
      seatNo - - the seat number of the player
      Returns:
      Player - player seated at the specified seat number
    • getCurTurnSeatNo

      public int getCurTurnSeatNo()
      Returns the seat number of the player whose turn is the current turn
      Returns:
      int - the seat number of the player whose turn is the current turn
    • getCurTurnPlayer

      public Player getCurTurnPlayer()
      Returns the player whose turn is the current turn
      Returns:
      Player - player whose turn is the current turn
    • getFirstFreeSeatno

      public int getFirstFreeSeatno()
      Returns the first free (not occupied) seat number.
      Returns:
      int - the first free seat number
    • getNextFreeSeatNo

      public int getNextFreeSeatNo​(int prevSeatNo)
      Returns the first free (not occupied) seat number after the specified seat number
      Parameters:
      prevSeatNo - - the previous seat number
      Returns:
      int - the first free seat number after prevSeatNo
    • debug

      public void debug​(String txt)
      Logs debug messages
      Parameters:
      txt - - the message to be logged
    • debug

      public void debug​(Session session, String txt)
      Logs debug messages along with the user name when debug is enabled
      Parameters:
      session - - the session whose user name should be prepended to the debug message
      txt - - the message to be logged
    • prepareJsonForClient

      protected abstract JsonObject prepareJsonForClient()
      Returns room Data to be sent to the client as part of the room state. Do not include fields defined in the base class Room such as roomId, roomName, etc For example in poker this data would be the table cards (flop,turn and river), the dealer seatNo, the pot values, the smallBlind etc
      Returns:
      JsonObject - the room data to be sent to client as json
    • getRoomInfo

      protected JsonObject getRoomInfo()
      Returns RoomInfo as json. RoomInfo is data that is sent to the client as part of the room list when client requests list of rooms in a given location. For example in poker this could be the smallBlind and the minimum chips to take seat
      Returns:
      JsonObject - the RoomInfo as json
    • onRoomJoined

      protected void onRoomJoined​(Session session)
      Event-Handler/Callback called after session is added to room but before joinedRoom message is sent to the client.
      Parameters:
      session - - the session that has joined the room
    • canSeatBeTaken

      protected boolean canSeatBeTaken​(Session session, int seatNo, JsonObject data)
      Callback called when a session takes seat to check whether session should be allowed to take seat or not. For example in poker if the chips the user wants to put on table is less than the minimum chips to take seat then this method should return false
      Parameters:
      session - - the session which is taking a seat
      seatNo - - the seat number
      data - - the data sent by the client with the takeSeat message: For example in poker this could be chipsToPutOnTable
      Returns:
      boolean - true to allow player to take seat
    • onSeatTaken

      protected void onSeatTaken​(Player player)
      Event-Handler/Callback called after player is seated but before seatTaken message is sent to clients. For example in poker here you could deduct the chip on table from the user's chips in Hand
      Parameters:
      player - - the player who took seat
    • afterSeatTaken

      protected void afterSeatTaken​(Player player)
      Event-Handler/Callback called after seatTaken message is sent. In this event you could call cancelAutoStartGame() to prevent a game autostart. A new game starts automatically if the minimum players required to start game are seated
      Parameters:
      player - - the player who took seat
    • beforeSeatLeft

      protected void beforeSeatLeft​(Player player, boolean isCurTurnPlayer, boolean isLeavingRoom, boolean isLoggingOut)
      Event-Handler/Callback called before player leaves/evicted from the seat. For eg. for a game like poker in this event you can add the player's chips on table to user's chips in hand. If the player leaving is in Game you can also play the default action of fold on the player
      Parameters:
      player - - the player who is leaving seat
      isCurTurnPlayer - - whether current turn is of the leaving player
      isLeavingRoom - - is the leave seat triggered as a result of leaving the room
      isLoggingOut - - is the leave seat triggered as a result of user loging out
    • afterSeatLeft

      protected void afterSeatLeft​(Player player, boolean isCurTurnPlayer, int noOfActivePlayers, boolean isLeavingRoom, boolean isLoggingOut)
      Event-Handler/Callback called after seat left message is sent
      Parameters:
      player - - the player who left seat
      isCurTurnPlayer - - whether current turn is of player which left
      noOfActivePlayers - - number of in game players
      isLeavingRoom - - is the leave seat triggered as a result of leaving the room
      isLoggingOut - - is the leave seat triggered as a result of user loging out
    • onRoomLeft

      protected void onRoomLeft​(Session session, boolean isLoggingOut)
      Event-Handler/Callback called after room Left but before room Left message is sent to player
      Parameters:
      session - - session which left room
      isLoggingOut - - is the leave room triggered as a result of user loging out
    • beforeGamePlayStarted

      protected void beforeGamePlayStarted()
      Event-Handler/Callback called before game play starts and new game play message is sent. In a game like poker you can deal the first cards and play the small blind and big blind in this event
    • afterGamePlayStarted

      protected Player afterGamePlayStarted()
      Event-Handler/Callback called after new game play message is sent - should return the first turn player
      Returns:
      Player - the player whose turn is first
    • onTurnTimedOut

      protected void onTurnTimedOut​(Player turnPlayer)
      Event-Handler/Callback called when player's turn times out. In this event you should play an action such as fold else turn will not move to the next player
      Parameters:
      turnPlayer - - the player whose turn timed out
    • onPlayerAction

      protected void onPlayerAction​(Player player, String action, JsonObject data, boolean isOutOfTurn)
      Event-Handler/Callback called when player plays turn - should call actionPlayed() (this will send turnPlayed or outOfTurnPlayed event/message to clients)
      Parameters:
      player - - the player who played the action
      action - - the action played
      data - - the action data
      isOutOfTurn - - is the action out of turn
    • afterTurnPlayed

      protected Player afterTurnPlayed​(Player player, String action, JsonObject actionData)
      Event-Handler/Callback called after player plays turn. Its is in this event that you should perform actions to be done after turn has completed. For example in poker if the betting round has completed you could deal the turn card. This method should return the player whose turn is next or null if the game has ended.
      Parameters:
      player - - the player who played the action
      action - - the action played
      actionData - - the action data
      Returns:
      - the player whose turn is next or null if the game has ended.
    • getNextTurnData

      protected abstract JsonObject getNextTurnData​(Player nextTurnPlayer)
      returns the data to be sent to the client along with the nextTurn event/message to clients. for example in poker this method could return the call value
      Parameters:
      nextTurnPlayer - - the player whose turn is next.
      Returns:
      JsonObject - the data to be sent to clients. for eg. {"callValue":20}
    • beforeGamePlayEnded

      protected JsonObject beforeGamePlayEnded()
      Event-Handler/Callback after endGamePlay() is called but before game play is ended. Should return endGame data to be sent to clients. For eg. the data could contain the winner, winning cards, etc
      Returns:
      JsonObject - the data to be sent to clients along with the endGame event/message.
    • afterGamePlayEnded

      protected void afterGamePlayEnded()
      Event-Handler/Callback called after game play has ended and endGamePlay message has been sent to clients. Here you can do actions such as adding the amount won to the winner's chips on table
    • getAdditionalRoomConfig

      protected abstract JsonObject getAdditionalRoomConfig()
      Should return the additional configuration data for the room. This method is called when a private room is saved to the database
      Returns:
      JsonObject - returns the additional configuration data for the room as json
    • setAdditionalRoomConfig

      protected abstract void setAdditionalRoomConfig​(JsonObject additionalRoomConfig)
      Should set the additional configuration data for the room. This method is called when a private room's configuration is changed
      Parameters:
      additionalRoomConfig - - the additional configuration data for the room
    • onRoomDestroyed

      protected void onRoomDestroyed()
      Event-Handler/Callback called when room is destroyed but before event/message is sent to clients. For eg in poker you could restore player's chips in hand in this event
    • afterRoomDestroyed

      protected void afterRoomDestroyed()
      Event-Handler/Callback called after Room is Destroyed and destroyed event/message is sent to clients. Do deinitialization here