C++ Client APIs
- initialize
- update
- connect
- disconnect
- initUDP
- joinLobby
- leaveLobby
- subscribeLobby
- unsubscribeLobby
- joinRoom
- joinRoomWithNUser
- joinRoomInUserRange
- leaveRoom
- createRoom
- deleteRoom
- setRecoveryAllowance
- subscribeRoom
- unsubscribeRoom
- sendChat
- sendPrivateChat
- sendUpdate
- sendMove
- getLiveRoomInfo
- getLiveUserInfo
- getLiveLobbyInfo
- setCustomUserData
- setCustomRoomData
- updateRoomProperties
- lockProperties
- unlockProperties
- getOnlineUsers
- recoverConnection
- createTurnRoom
- startGame
- setNextTurn
- stopGame
- getMoveHistory
- getAllRooms
- getRoomWithNUser
- getRoomsInUserRange
- getRoomWithProperties
- setZoneRequestListener
- setRoomRequestListener
- setLobbyRequestListener
- setNotificationListener
- setConnectionRequestListener
- setUpdateRequestListener
- setChatRequestListener
- setGeo
static void initialize ( std :: string apiKey , std :: string secretKey );
Parameters
apiKey - The Application key given when the application was created. secretKey - The secret key corresponding to the application key given when the application was created.
Returns
void
void Update ();
Parameters
Returns
void
void connect ( std :: string username );
Parameters
username - Username of the player
Returns
void
void disconnect ();
Parameters
Returns
void
void initUDP();
Parameters
Returns
void
void join Lobby ();
Parameters
Returns
void
void leave Lobby ();
Parameters
Returns
void
void subscribe Lobby ();
Parameters
Returns
void
void unsubscribe Lobby ();
Parameters
Returns
void
void join Room ( std :: string roomId );
Parameters
roomId - Id of the room to be joined
Returns
void
void join Room With NUser ( int userCount );
Parameters
userCount- number of users in room to be joined
Returns
void
void joinRoomInUserRange ( int minJoinedUsers , int maxJoinedUsers , bool maxPreferred );
Parameters
userCount- number of users in room to be joined
Returns
void
void joinRoomWithProperties( std :: map < std :: string , std :: string > tableProperties );
Parameters
tableProperties- properties of the room to be joined
Returns
void
void leaveRoom ( std :: string roomId );
Parameters
roomId - Id of the room to be left
Returns
void
void createRoom ( std :: string name , std :: string owner , int maxUsers , std :: map < std :: string , std :: string > tableProperties );
Parameters
name - name of the room owner - administrator of the room maxUsers - number of maximum users allowed in the room tableProperties - properties of room for matchmaking ( pass null if not required )
Returns
void
void deleteRoom ( std :: tring roomId );
Parameters
roomId - Id of the room to be deleted
Returns
void
void subscribeRoom ( std :: string roomId );
Parameters
roomId - Id of the room to be subscribed
Returns
‘void’
void unsubscribeRoom ( std :: string roomId );
Parameters
roomId - Id of the room to be subscribed
Returns
void
void sendChat ( std :: string message );
Parameters
message - message to be send
Returns
void
void sendPrivateChat ( std :: string toUser , std :: string message )
Sends a private message to the given user if its online. Result of the request is provided in the onSendPrivateChatDone callback of the registered ChatRequestListener objects. The sender and receiver don’t need to be in the same room or lobby for the private message to be delivered. This is useful in building invite/challenge friend like scenarios. If successful, the receiver will get a onPrivateChatReceived event on its registered NotifyListener objects.
Parameters
toUser - the recipient of the private chat
message - message to be send
Returns
void
void sendUpdate ( byte * update , int updateLength );
Parameters
update - binary data to be send
Returns
void
void getLiveRoomInfo ( std :: string roomId );
Parameters
roomId - Id of the room
Returns
void
void getLiveUserInfo ( std :: string username );
Parameters
username - user who's information is requested
Returns
void
void getLiveLobbyInfo ();
Parameters
Returns
void
void setCustomUserData ( std :: string userName , std :: string customData );
Parameters
userName - user for whom custom data has to be update customData - custom data that will be set for the user
Returns
void
Updates the custom data associated with the given room on the server. The result is provided in the onSetCustomRoomDataDone callback of the registered RoomRequestListener objects. It is recommended you use the room’s properties where ever possible. Use this when you need to associate data with a room which can not be represented as key value pairs.
void SetCustomRoomData ( std :: string roomId , std :: string customRoomData )
Parameters
roomId - Id of the room customRoomData - custom data that will be set for the room
Returns
void
void updateRoomProperties ( std :: string roomID , std :: map < std :: string , std :: string > tableProperties , std :: vector < std :: string > removeArray );
Parameters
roomId - Id of the room tableProperties - properties that will be set for the room removeArray - properties that will be removed for the room
Returns
void
void lockProperties ( std :: map < std :: string , std :: string > properties );
Lock the properties associated with the joined room on the server for requested user. Result is provided in the onLockPropertyDone callback of the registered RoomRequestListener objects. Lock properties will fail if any other user has lock on same property, otherwise property will be added in lockTable with owner name. This request (if successful) will also result in an onUserChangeRoomProperty notification on the registered NotifyListener objects to be triggered for all subscribed users of the room.
Parameters
properties - properties and their values to be locked
Returns
void
void unlockProperties ( std :: vector < std :: string > properties );
Unlock the properties associated with the joined room on the server for requested user. Result is provided in the onUnlockPropertyDone callback of the registered RoomRequestListener objects. Unlock properties will fail if any other user has lock on same property, otherwise property will be removed from lock table. This request (if successful) will also result in an onUserChangeRoomProperty notification on the registered NotifyListener objects to be triggered for all subscribed users of the room.
Parameters
properties - vector of properties to be unlocked
Returns
void
void getOnlineUsers ();
Parameters
Returns
void
void getAllRooms ();
Parameters
Returns
void
void getRoomWithNUser ( int userCount );
Parameters
userCount- number of users in room to be joined
Returns
void
void getRoomsInUserRange ( int minJoinedUsers , int maxJoinedUsers );
Parameters
minJoinedUsers- minimum number of users in room to be joined
maxJoinedUsers- maximum number of users in room to be joined
Returns
void
void getRoomWithProperties ( std :: map < std :: string , std :: string > properties );
Parameters
properties- properties of the room to be joined
Returns
void
void setZoneRequestListener ( ZoneRequestListener * listener );
Parameters
listener - method for listening to the request
Returns
void
void setRoomRequestListener ( RoomRequestListener * listener );
Parameters
listener - method for listening to the request
Returns
void
void setLobbyRequestListener ( LobbyRequestListener * listener );
Parameters
listener - method for listening to the request
Returns
void
public void setNotificationListener ( NotifyListener * listener );
Parameters
listener - method for listening to the request
Returns
void
void addConnectionRequestListener ( ConnectionRequestListener * listener )
Parameters
listener - method for listening to the request
Returns
void
Registers the given listener object to the list of objects on which callbacks will be invoked when a response from the server is received for a SendUpdatePeers request. The object must implement the UpdateRequestListener interface.
void AddUpdateRequestListener ( UpdateRequestListener * listener )
Parameters
listener - listener object
Returns
void
Registers the given listener object to the list of objects on which callbacks will be invoked when a response from the server is received for a SendChat request. The object must implement the ChatRequestListener interface.
public void AddChatRequestListener ( ChatRequestListener * listener )
Parameters
listener - listener object
Returns
void
Sends a start game request to the server. Result of the request is provided in the onGameStarted callback of the TurnBasedRoomListener.
void startGame(bool isDefaultLogic=true, std::string firstTurn = "");
Parameters
isDefaultLogic - set it false if server logic need to be overridden
firstTurn - By default goes empty if server's default turn-based logic need to be followed. User name whose turn will be first in your custom turn-based system
Returns
void
When the onNextTurnRequest is sent by the server, one can call this api to set the next turn to the server for the joined turn based room.Result of the request is provided in the onSetNextTurnDone callback of the registered Turn Based Room Listener objects. If the joined user is not in turn based room or if it’s not the user’s turn, this request will fail. If successful, this will result in onMoveCompleted notification for all the subscribed users on the registered NotifyListener objects.
void setNextTurn(std::string nextTurn);
Parameters
nextTurn - User name whose turn is next
Returns
void
Sends a stop game request to the server. Result of the request is provided in the onGameStopped callback of the TurnBasedRoomListener.
stopGame ( )
Returns
void
Sends a get move history request to the server. Result of the request is provided in the onGetMoveHistoryDone callback of the TurnBasedRoomListener.
getMoveHistory ( )
Returns
void
Sends a create turn based room request to the server with the given meta data. Result of the request is provided in the onCreateRoomDone callback of the registered ZoneRequestListener objects. If successful, this will create a dynamic turn based room at the server. These rooms lifetime is limited till the time users are inside it. Read more about Rooms here.
public void createTurnRoom ( String name , String owner , int maxUsers , std::map < std::string , std::string > tableProperties , int turnTime )
Parameters
name - name of the room owner - owner of the room ( behavior and usage of this meta property is up to the developer ) maxUsers - number of maximum users allowed in the room tableProperties - properties of room ( can be null ) turnTime - the time ( in seconds ) allowed for a user to complete its turn and send a move .
Returns
void
Sends a move to the server for the joined turn based room.Result of the request is provided in the onSendMoveDone callback of the registered TurnBasedRoomListener objects. If the joined user is not a turn based room or if its not the users turn, this request will fail. If successful, this will result in onMoveCompleted notification for all the subscribed users on the registered NotifyListener objects.
void sendMove(std::string movedata, std::string nextTurn = "");
Parameters
moveData - any meta data associated with the move
nextTurn - name of the player whose turn you want to set next
Returns
void
public void setRecoveryAllowance ( int maxRecoveryTime )
Parameters
maxRecoveryTime - time - the time (in seconds) allowed to the client to recover from intermittent connection loss
Returns
void
public void recoverConnection ( )
Parameters
Returns
void
setGeo allows you to connect to our cloud servers in locations other than the default location. This offers developers the choice to connect to the closest server depending on the client’s device location.
public void setGeo(std::string _geo)
Parameters
_geo - server location. For e.g. US, EU, JAPAN
Returns
void