Package io.sockit.gameclient

This is the core package for the Sockit Game Client and provides the classes necessary to implement the client (front end) side of a multiplayer game side of a multiplayer turn based game. Clients should only input user events/actions and render the game. Below are some of the core classes in this package

Client This class represents a Client interacting with the server. It has methods to login a User to the Server, enter a game, fetch list of rooms, join a room, etc. See startup code example below


      // instantiate a client with the server url
       Client client = new Client("ws://localhost"); 
      // register a ClientEventListener (event/callback handler) with the client
       client.setClientEventListener(new TicTacToeClientListener());
      // register user and login to the server with emailId, password, user name and game name as parameters
       client.registerWithEmailId("a@a.com", "123", "Rohan", "TicTacToe");
  

ClientEventListener Interface for Client events/callbacks. An instance of this interface should be registered with the client object to handle async events received from the server


      public class TicTacToeClientListener implements ClientEventListener {
          {@literal @}Override
          public void onLoggedIn(Client client, boolean isGameSelected) {
              if(isGameSelected)
                  client.getRooms( "Mumbai", RoomType.normal); //fetches room list from Mumbai location
          }
 
          {@literal @}Override
          public void onGetRooms(Client client, String gameName, String location, RoomType roomtype, List<RoomInfo> rooms) {
              client.joinRoom(rooms.get(0).roomId); //joins the first room in the list
          }
         //....
      }
  

Room This class represents a Game Room. An instance of this class is passed to many of the event/callback methods and can be used to render the room and game play onto the UI

Player This class represents a Player seated in the room and can be used to render a player onto the UI

  • Interface Summary 
    Interface Description
    ClientEventListener
    Interface for Client events/callbacks.
    ErrorLogger
    Interface for logging errors
  • Class Summary 
    Class Description
    Client
    This class represents a Client interacting with the server.
    ClientEventAdapter
    An abstract adapter class for receiving client events.
    ErrorCodes
    This class defines the list of Error codes sent by the server This object/function prototype defines the list of Error codes sent by the server
    JsonUtil
    This class contains convenience/utility methods for the java Json processing api.
    Player
    This class represents a Player seated in the room and can be used to render a player onto the UI This object/function prototype represents a Player seated in the room and can be used to render a player onto the UI
    Room
    This class represents a game room.
    RoomInfo
    This class represents the key info for each room in the room list This object/function prototype represents the key info for each room in the room list
  • Enum Summary 
    Enum Description
    LoginType
    Enumeration of the possible LoginTypes
    RoomType
    Enumeration of the possible room types
    ServerMessageType
    Enumeration of the possible Server message types
  • Exception Summary 
    Exception Description
    GamePlayNotInProgressException
    Exception thrown when GamePlay has not started and Client invokes playAction() method