Interface BotEventListener

All Known Implementing Classes:
BotEventAdapter

public interface BotEventListener
Interface for Bot events/callbacks. An instance of this interface should be registered with the bot object to handle async events received from the server

      public class TicTacToeBotListener implements BotEventListener {
          {@literal @}Override
          public void onLoggedIn(Bot bot) {
              bot.getRooms( "Mumbai", RoomType.normal); //fetches room list from Mumbai location
          }
 
          {@literal @}Override
          public void onGetRooms(Bot bot, String gameName, String location, RoomType roomtype, List<RoomInfo> rooms) {
              bot.joinRoom(rooms.get(0).roomId); //joins the first room in the list
          }
          ....
      }
  
  • Method Summary

    Modifier and Type Method Description
    void onAvtarChangedOfOtherPlayer​(Bot bot, Player player, int newAvtarId, Room room)
    Event-Handler/Callback called when the avtar of another player is changed
    void onAvtarChangedOfSelf​(Bot bot, int newAvtarId)
    Event-Handler/Callback called when the avtar of the user loggedIn via this bot changes
    void onError​(Bot bot, int errorCode, String errorDesc)
    Event-Handler/Callback called when an error is triggered on the server.
    void onGameAction​(Bot bot, String gameAction, JsonObject actionData, Room room)
    Event-Handler/Callback called when a game action occurs in the game.
    void onGamePlayEnded​(Bot bot, Room room, JsonObject endGameData)
    Event-Handler/Callback called when game play ends in the room
    void onGamePlayStarted​(Bot bot, Room room)
    Event-Handler/Callback called when game play starts in the room
    void onGetLocations​(Bot bot, String gameName, List<String> locations)
    Event-Handler/Callback called when the Bot receives the location list from the Server
    void onGetRooms​(Bot bot, String gameName, String location, RoomType roomtype, List<RoomInfo> rooms)
    Event-Handler/Callback called when the Bot receives the room list from the Server
    void onInvalidAction​(Bot bot, String action, String description, JsonObject errorData, Room room, boolean isOutOfTurn)
    Event-Handler/Callback called when an action played by the Bot is not valid
    void onLoggedIn​(Bot bot)
    Event-Handler/Callback called when the Bot successfully logins into the server
    void onLoggedOut​(Bot bot)
    Event-Handler/Callback called when the Bot successfully logouts from the server
    void onMessageReceivedBytes​(Bot bot, String command, byte[] data)
    Event-Handler/Callback called when the Bot receives a custom binary message from the server
    void onMessageReceivedJson​(Bot bot, String command, JsonObject data)
    Event-Handler/Callback called when the Bot receives a custom Json message from the server
    void onMessageReceivedString​(Bot bot, String command, String data)
    Event-Handler/Callback called when the Bot receives a custom text message from the server
    void onNextTurn​(Bot bot, Player turnPlayer, JsonObject turnData, Room room, boolean isSelfTurn)
    Event-Handler/Callback called when a new turn begins
    void onNotEligibleToPlay​(Bot bot, Player player, Room room, String reason)
    Event-Handler/Callback called when the Bot is not eligible to play the new game play that is starting
    void onOutOfTurnPlayed​(Bot bot, Player outOfTurnPlayer, String playerAction, JsonObject actionData, Room room, boolean isSelf)
    Event-Handler/Callback called when an action is played out of turn by a player
    void onRoomDestroyed​(Bot bot, Room room)
    Event-Handler/Callback called when the room joined by this bot is destroyed
    void onRoomJoined​(Bot bot, Room room)
    Event-Handler/Callback called when the Bot joins a room
    void onRoomLeft​(Bot bot)
    Event-Handler/Callback called when the Bot leaves the room
    void onRoomRefreshedFromServer​(Bot bot, Room room)
    Event-Handler/Callback called when the room state is refreshed from the server.
    void onSeatLeft​(Bot bot, Player playerLeft, Room room, boolean isSelf)
    Event-Handler/Callback called when any user leaves a seat in the room.
    void onSeatTaken​(Bot bot, Player playerSeated, Room room, boolean isSelf)
    Event-Handler/Callback called when any user takes a seat in the room.
    void onServerShutdown​(Bot bot)
    Event-Handler/Callback called when the server shutsdown
    void onSessionTimedOut​(Bot bot)
    Event-Handler/Callback called when the Bot's session times out on the server
    void onTurnPlayed​(Bot bot, Player turnPlayer, String playerAction, JsonObject actionData, Room room, boolean isSelf)
    Event-Handler/Callback called when a player plays his/her turn
  • Method Details

    • onError

      void onError​(Bot bot, int errorCode, String errorDesc)
      Event-Handler/Callback called when an error is triggered on the server.
      Parameters:
      bot - - the Bot which triggered the error
      errorCode - - the errorCode e.g. ErrorCodes.emailIdAndPasswordDoesNotMatch or ErrorCodes.seatNotFree or ...
      errorDesc - - the error description
    • onLoggedIn

      void onLoggedIn​(Bot bot)
      Event-Handler/Callback called when the Bot successfully logins into the server
      Parameters:
      bot - - the Bot which loggedIn
    • onLoggedOut

      void onLoggedOut​(Bot bot)
      Event-Handler/Callback called when the Bot successfully logouts from the server
      Parameters:
      bot - - the bot which loggedOut
    • onSessionTimedOut

      void onSessionTimedOut​(Bot bot)
      Event-Handler/Callback called when the Bot's session times out on the server
      Parameters:
      bot - - the bot whose session timed out
    • onServerShutdown

      void onServerShutdown​(Bot bot)
      Event-Handler/Callback called when the server shutsdown
      Parameters:
      bot - - the Bot which triggered this event
    • onGetLocations

      void onGetLocations​(Bot bot, String gameName, List<String> locations)
      Event-Handler/Callback called when the Bot receives the location list from the Server
      Parameters:
      bot - - the Bot which triggered this event
      gameName - - the name of the game whose locations were requested by the Bot
      locations - - the list of locations
    • onGetRooms

      void onGetRooms​(Bot bot, String gameName, String location, RoomType roomtype, List<RoomInfo> rooms)
      Event-Handler/Callback called when the Bot receives the room list from the Server
      Parameters:
      bot - - the Bot which triggered this event
      gameName - - the name of the game whose room list was requested by the Bot
      location - - the location whose room list was requested
      roomtype - - the type of room list e.g. RoomType.normal or RoomType.fast
      rooms - - the room list as a collection of RoomInfo objects
    • onRoomJoined

      void onRoomJoined​(Bot bot, Room room)
      Event-Handler/Callback called when the Bot joins a room
      Parameters:
      bot - - the Bot which triggered this event
      room - - the room joined by this Bot
    • onRoomRefreshedFromServer

      void onRoomRefreshedFromServer​(Bot bot, Room room)
      Event-Handler/Callback called when the room state is refreshed from the server. Gets triggered when Bot receives a ServerMessageType.roomData message from the Server
      Parameters:
      bot - - the Bot which triggered this event
      room - - the room joined by the bot
    • onSeatTaken

      void onSeatTaken​(Bot bot, Player playerSeated, Room room, boolean isSelf)
      Event-Handler/Callback called when any user takes a seat in the room.
      Parameters:
      bot - - the Bot which receives this event
      playerSeated - - the player which took seat
      room - - the room joined by this bot
      isSelf - - if the user seated is the same as this Bot
    • onSeatLeft

      void onSeatLeft​(Bot bot, Player playerLeft, Room room, boolean isSelf)
      Event-Handler/Callback called when any user leaves a seat in the room.
      Parameters:
      bot - - the Bot which receives this event
      playerLeft - - the player which left the seat
      room - - the room joined by this bot
      isSelf - - if the user which left is the same as this Bot
    • onRoomLeft

      void onRoomLeft​(Bot bot)
      Event-Handler/Callback called when the Bot leaves the room
      Parameters:
      bot - - the Bot which triggered this event
    • onMessageReceivedJson

      void onMessageReceivedJson​(Bot bot, String command, JsonObject data)
      Event-Handler/Callback called when the Bot receives a custom Json message from the server
      Parameters:
      bot - - the Bot which receives the message
      command - - the message command
      data - - the message data as json
    • onMessageReceivedString

      void onMessageReceivedString​(Bot bot, String command, String data)
      Event-Handler/Callback called when the Bot receives a custom text message from the server
      Parameters:
      bot - - the Bot which receives the message
      command - - the message command
      data - - the message data as String
    • onMessageReceivedBytes

      void onMessageReceivedBytes​(Bot bot, String command, byte[] data)
      Event-Handler/Callback called when the Bot receives a custom binary message from the server
      Parameters:
      bot - - the Bot which receives the message
      command - - the message command
      data - - the message data as a byte array
    • onGamePlayStarted

      void onGamePlayStarted​(Bot bot, Room room)
      Event-Handler/Callback called when game play starts in the room
      Parameters:
      bot - - the Bot which receives this event
      room - - the room joined by this bot
    • onNextTurn

      void onNextTurn​(Bot bot, Player turnPlayer, JsonObject turnData, Room room, boolean isSelfTurn)
      Event-Handler/Callback called when a new turn begins
      Parameters:
      bot - - the Bot which receives this event
      turnPlayer - - the player whose turn it is
      turnData - - the additional data received with the event. For e.g. in a game like Poker it could be {"callValue":20}
      room - - the room joined by this bot
      isSelfTurn - - whether its the turn of the bot which received this event
    • onTurnPlayed

      void onTurnPlayed​(Bot bot, Player turnPlayer, String playerAction, JsonObject actionData, Room room, boolean isSelf)
      Event-Handler/Callback called when a player plays his/her turn
      Parameters:
      bot - - the Bot which receives this event
      turnPlayer - - the player who played the action
      playerAction - - the action played by the player
      actionData - - the action data if any. For e.g. in a game like Poker it could be {"amtBet":20}
      room - - the room joined by this bot
      isSelf - - whether the action was played by the bot which received this event
    • onOutOfTurnPlayed

      void onOutOfTurnPlayed​(Bot bot, Player outOfTurnPlayer, String playerAction, JsonObject actionData, Room room, boolean isSelf)
      Event-Handler/Callback called when an action is played out of turn by a player
      Parameters:
      bot - - the Bot which receives this event
      outOfTurnPlayer - - the player who played the action
      playerAction - - the action played by the player
      actionData - - the action data if any.
      room - - the room joined by this bot
      isSelf - - whether the action was played by the bot which received this event
    • onGameAction

      void onGameAction​(Bot bot, String gameAction, JsonObject actionData, Room room)
      Event-Handler/Callback called when a game action occurs in the game. For e.f. in a game like poker this could be flop cards dealt
      Parameters:
      bot - - the Bot which receives this event
      gameAction - - the game action
      actionData - - the action data. For e.g. in a game like poker this could be the value of the flop cards
      room - - the room joined by this bot
    • onGamePlayEnded

      void onGamePlayEnded​(Bot bot, Room room, JsonObject endGameData)
      Event-Handler/Callback called when game play ends in the room
      Parameters:
      bot - - the Bot which receives this event
      room - - the room joined by this bot
      endGameData - - the data received with the endGame event. For e.g this could be the winning seat no and the amount won
    • onRoomDestroyed

      void onRoomDestroyed​(Bot bot, Room room)
      Event-Handler/Callback called when the room joined by this bot is destroyed
      Parameters:
      bot - - the Bot which receives this event
      room - - the room which was destroyed
    • onAvtarChangedOfSelf

      void onAvtarChangedOfSelf​(Bot bot, int newAvtarId)
      Event-Handler/Callback called when the avtar of the user loggedIn via this bot changes
      Parameters:
      bot - - the Bot which receives this event
      newAvtarId - - the new avtarId of the user
    • onAvtarChangedOfOtherPlayer

      void onAvtarChangedOfOtherPlayer​(Bot bot, Player player, int newAvtarId, Room room)
      Event-Handler/Callback called when the avtar of another player is changed
      Parameters:
      bot - - the Bot which receives this event
      player - - the player whose avtar is changed
      newAvtarId - - the new avtarID
      room - - the room joined by this bot
    • onNotEligibleToPlay

      void onNotEligibleToPlay​(Bot bot, Player player, Room room, String reason)
      Event-Handler/Callback called when the Bot is not eligible to play the new game play that is starting
      Parameters:
      bot - - the Bot which receives this event
      player - - the player linked to this bot
      room - - the room joined by this bot
      reason - - the reason why player is not eligible
    • onInvalidAction

      void onInvalidAction​(Bot bot, String action, String description, JsonObject errorData, Room room, boolean isOutOfTurn)
      Event-Handler/Callback called when an action played by the Bot is not valid
      Parameters:
      bot - - the Bot which triggers this event
      action - - the action played
      description - - the error description
      errorData - - the error data containing more info about the error
      room - - the room joined by the bot
      isOutOfTurn - - true if the action was played out of turn