Package io.sockit.gameserver.bot
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 voidonAvtarChangedOfOtherPlayer(Bot bot, Player player, int newAvtarId, Room room)Event-Handler/Callback called when the avtar of another player is changedvoidonAvtarChangedOfSelf(Bot bot, int newAvtarId)Event-Handler/Callback called when the avtar of the user loggedIn via this bot changesvoidonError(Bot bot, int errorCode, String errorDesc)Event-Handler/Callback called when an error is triggered on the server.voidonGameAction(Bot bot, String gameAction, JsonObject actionData, Room room)Event-Handler/Callback called when a game action occurs in the game.voidonGamePlayEnded(Bot bot, Room room, JsonObject endGameData)Event-Handler/Callback called when game play ends in the roomvoidonGamePlayStarted(Bot bot, Room room)Event-Handler/Callback called when game play starts in the roomvoidonGetLocations(Bot bot, String gameName, List<String> locations)Event-Handler/Callback called when the Bot receives the location list from the ServervoidonGetRooms(Bot bot, String gameName, String location, RoomType roomtype, List<RoomInfo> rooms)Event-Handler/Callback called when the Bot receives the room list from the ServervoidonInvalidAction(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 validvoidonLoggedIn(Bot bot)Event-Handler/Callback called when the Bot successfully logins into the servervoidonLoggedOut(Bot bot)Event-Handler/Callback called when the Bot successfully logouts from the servervoidonMessageReceivedBytes(Bot bot, String command, byte[] data)Event-Handler/Callback called when the Bot receives a custom binary message from the servervoidonMessageReceivedJson(Bot bot, String command, JsonObject data)Event-Handler/Callback called when the Bot receives a custom Json message from the servervoidonMessageReceivedString(Bot bot, String command, String data)Event-Handler/Callback called when the Bot receives a custom text message from the servervoidonNextTurn(Bot bot, Player turnPlayer, JsonObject turnData, Room room, boolean isSelfTurn)Event-Handler/Callback called when a new turn beginsvoidonNotEligibleToPlay(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 startingvoidonOutOfTurnPlayed(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 playervoidonRoomDestroyed(Bot bot, Room room)Event-Handler/Callback called when the room joined by this bot is destroyedvoidonRoomJoined(Bot bot, Room room)Event-Handler/Callback called when the Bot joins a roomvoidonRoomLeft(Bot bot)Event-Handler/Callback called when the Bot leaves the roomvoidonRoomRefreshedFromServer(Bot bot, Room room)Event-Handler/Callback called when the room state is refreshed from the server.voidonSeatLeft(Bot bot, Player playerLeft, Room room, boolean isSelf)Event-Handler/Callback called when any user leaves a seat in the room.voidonSeatTaken(Bot bot, Player playerSeated, Room room, boolean isSelf)Event-Handler/Callback called when any user takes a seat in the room.voidonServerShutdown(Bot bot)Event-Handler/Callback called when the server shutsdownvoidonSessionTimedOut(Bot bot)Event-Handler/Callback called when the Bot's session times out on the servervoidonTurnPlayed(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
Event-Handler/Callback called when an error is triggered on the server.- Parameters:
bot- - the Bot which triggered the errorerrorCode- - the errorCode e.g. ErrorCodes.emailIdAndPasswordDoesNotMatch or ErrorCodes.seatNotFree or ...errorDesc- - the error description
-
onLoggedIn
Event-Handler/Callback called when the Bot successfully logins into the server- Parameters:
bot- - the Bot which loggedIn
-
onLoggedOut
Event-Handler/Callback called when the Bot successfully logouts from the server- Parameters:
bot- - the bot which loggedOut
-
onSessionTimedOut
Event-Handler/Callback called when the Bot's session times out on the server- Parameters:
bot- - the bot whose session timed out
-
onServerShutdown
Event-Handler/Callback called when the server shutsdown- Parameters:
bot- - the Bot which triggered this event
-
onGetLocations
Event-Handler/Callback called when the Bot receives the location list from the Server- Parameters:
bot- - the Bot which triggered this eventgameName- - the name of the game whose locations were requested by the Botlocations- - 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 eventgameName- - the name of the game whose room list was requested by the Botlocation- - the location whose room list was requestedroomtype- - the type of room list e.g. RoomType.normal or RoomType.fastrooms- - the room list as a collection of RoomInfo objects
-
onRoomJoined
Event-Handler/Callback called when the Bot joins a room- Parameters:
bot- - the Bot which triggered this eventroom- - the room joined by this Bot
-
onRoomRefreshedFromServer
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 eventroom- - the room joined by the bot
-
onSeatTaken
Event-Handler/Callback called when any user takes a seat in the room.- Parameters:
bot- - the Bot which receives this eventplayerSeated- - the player which took seatroom- - the room joined by this botisSelf- - if the user seated is the same as this Bot
-
onSeatLeft
Event-Handler/Callback called when any user leaves a seat in the room.- Parameters:
bot- - the Bot which receives this eventplayerLeft- - the player which left the seatroom- - the room joined by this botisSelf- - if the user which left is the same as this Bot
-
onRoomLeft
Event-Handler/Callback called when the Bot leaves the room- Parameters:
bot- - the Bot which triggered this event
-
onMessageReceivedJson
Event-Handler/Callback called when the Bot receives a custom Json message from the server- Parameters:
bot- - the Bot which receives the messagecommand- - the message commanddata- - the message data as json
-
onMessageReceivedString
Event-Handler/Callback called when the Bot receives a custom text message from the server- Parameters:
bot- - the Bot which receives the messagecommand- - the message commanddata- - the message data as String
-
onMessageReceivedBytes
Event-Handler/Callback called when the Bot receives a custom binary message from the server- Parameters:
bot- - the Bot which receives the messagecommand- - the message commanddata- - the message data as a byte array
-
onGamePlayStarted
Event-Handler/Callback called when game play starts in the room- Parameters:
bot- - the Bot which receives this eventroom- - the room joined by this bot
-
onNextTurn
Event-Handler/Callback called when a new turn begins- Parameters:
bot- - the Bot which receives this eventturnPlayer- - the player whose turn it isturnData- - 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 botisSelfTurn- - 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 eventturnPlayer- - the player who played the actionplayerAction- - the action played by the playeractionData- - the action data if any. For e.g. in a game like Poker it could be {"amtBet":20}room- - the room joined by this botisSelf- - 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 eventoutOfTurnPlayer- - the player who played the actionplayerAction- - the action played by the playeractionData- - the action data if any.room- - the room joined by this botisSelf- - whether the action was played by the bot which received this event
-
onGameAction
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 eventgameAction- - the game actionactionData- - the action data. For e.g. in a game like poker this could be the value of the flop cardsroom- - the room joined by this bot
-
onGamePlayEnded
Event-Handler/Callback called when game play ends in the room- Parameters:
bot- - the Bot which receives this eventroom- - the room joined by this botendGameData- - the data received with the endGame event. For e.g this could be the winning seat no and the amount won
-
onRoomDestroyed
Event-Handler/Callback called when the room joined by this bot is destroyed- Parameters:
bot- - the Bot which receives this eventroom- - the room which was destroyed
-
onAvtarChangedOfSelf
Event-Handler/Callback called when the avtar of the user loggedIn via this bot changes- Parameters:
bot- - the Bot which receives this eventnewAvtarId- - the new avtarId of the user
-
onAvtarChangedOfOtherPlayer
Event-Handler/Callback called when the avtar of another player is changed- Parameters:
bot- - the Bot which receives this eventplayer- - the player whose avtar is changednewAvtarId- - the new avtarIDroom- - the room joined by this bot
-
onNotEligibleToPlay
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 eventplayer- - the player linked to this botroom- - the room joined by this botreason- - 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 eventaction- - the action playeddescription- - the error descriptionerrorData- - the error data containing more info about the errorroom- - the room joined by the botisOutOfTurn- - true if the action was played out of turn
-