HTML5 Client APIs
- initialize
- getInstance
- getSessionID
- connect
- disconnect
- recoverConnection
- recoverConnectionWithSessionID
- setRecoveryAllowance
- joinLobby
- leaveLobby
- subscribeLobby
- unsubscribeLobby
- joinRoom
- joinRoomInRange
- JoinRoomWithProperties
- leaveRoom
- createRoom
- deleteRoom
- setGeoLocation
- subscribeRoom
- unsubscribeRoom
- sendChat
- sendPrivateChat
- sendUpdatePeers
- getLiveRoomInfo
- getLiveUserInfo
- getLiveLobbyInfo
- setCustomUserData
- setCustomRoomData
- updateRoomProperties
- lockProperties
- unlockProperties
- getOnlineUsers
- getAllRooms
- getRoomInRange
- getRoomWithProperties
- createTurnRoom
- sendMove
- setResponseListener
- resetResponseListener
- setNotifyListener
- resetNotifyListener
- startGame
- stopGame
- getMoveHistory
- setNextTurn
- sendPrivateUpdatePeers
- getOnlineUsersCount
- getAllRoomsCount
- joinAndSubscribeRoom
- leaveAndUnsubscribeRoom
- getRoomInRangeWithProp
- getUserStatus
- sendChat(overloaded method for chat history)
- setDbName
- enableChatHistory
- getChatHistory
AppWarp.WarpClient.initialize(apiKey, 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
AppWarp.WarpClient.getInstance();
Returns
WarpClient
getSessionID();
Returns
SessionID - int sessionID
connect(username);
Parameters
username - Username of the player
Returns
void
disconnect();
Parameters
Returns
void
recoverConnection();
Returns
void
recoverConnectionWithSessionID(sessionID, userName);
Parameters
sessionID- sessionId of the last successful session. userName- name of the player.
Returns
void
setRecoveryAllowance(time);
Parameters
time - the time (in seconds) allowed to the client to recover from intermittent connection loss.
Returns
void
joinLobby();
Parameters
Returns
void
leaveLobby();
Parameters
Returns
void
subscribeLobby();
Parameters
Returns
void
unsubscribeLobby();
Parameters
Returns
void
joinRoom(roomId);
Parameters
roomId - Id of the room to be joined
Returns
void
joinRoomInRange(minJoinedUsers, maxJoinedUsers, maxPreferred);
Parameters
minJoinedUsers - minimum number of users joined in room
maxJoinedUsers - maximum number of users joined in room
maxPreferred - Prefer room with maximum joined users
Returns
void
joinRoomWithProperties(tableProperties);
Parameters
tableProperties- properties of the room to be joined
Returns
void
leaveRoom(roomId);
Parameters
roomId - Id of the room to be left
Returns
void
createRoom(name, owner, maxUsers, 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
deleteRoom(roomId);
Parameters
roomId - Id of the room to be deleted
Returns
void
subscribeRoom(roomId);
Parameters
roomId - Id of the room to be subscribed
Returns
‘void’
unsubscribeRoom(roomId);
Parameters
roomId - Id of the room to be subscribed
Returns
void
sendChat(message);
Parameters
message - message to be send
Returns
void
sendPrivateChat(toUser, message)
Sends a private message to the given user if its online. Result of the request is provided in the onSendPrivateChatDone callback. 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 callback.
Parameters
toUser - the recipient of the private chat
message - message to be send
Returns
void
sendUpdatePeers(update);
Parameters
update - binary data to be send
Returns
void
getLiveRoomInfo(roomId);
Parameters
roomId - Id of the room
Returns
void
getLiveUserInfo(username);
Parameters
username - user who's information is requested
Returns
void
getLiveLobbyInfo();
Parameters
Returns
void
WarpClient.setCustomUserData(userName, 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. 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.
SetCustomRoomData(roomId, customRoomData)
Parameters
roomId - Id of the room customRoomData - custom data that will be set for the room
Returns
void
updateRoomProperties(roomID, tableProperties, 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
lockProperties(properties);
Lock the properties associated with the joined room on the server for requested user. Result is provided in the onLockPropertyDone callback. 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 to be triggered for all subscribed users of the room.
Parameters
properties - properties and their values to be locked
Returns
void
unlockProperties(properties);
Unlock the properties associated with the joined room on the server for requested user. Result is provided in the onUnlockPropertyDone callback. 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 to be triggered for all subscribed users of the room.
Parameters
properties - vector of properties to be unlocked
Returns
void
getOnlineUsers();
Parameters
Returns
void
getAllRooms();
Parameters
Returns
void
getRoomsInRange(minJoinedUsers, maxJoinedUsers);
Parameters
minJoinedUsers- minimum number of users in room to be joined
maxJoinedUsers- maximum number of users in room to be joined
Returns
void
getRoomWithProperties(properties);
Parameters
properties- properties of the room to be joined
Returns
void
setResponseListener(event, callback);
Parameters
event - Event to be registered
callback - Callback Function
Returns
void
setNotifyListener(event, callback);
Parameters
event - Event to be registered
callback - Callback Function
Returns
void
resetNotifyListener(event);
Parameters
event - Event to be registered
callback - Callback Function
Returns
void
resetResponseListener(event);
Parameters
event - Event to be registered
callback - Callback Function
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. 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.
createTurnRoom (name ,owner , maxUsers , tableProperties , 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. 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 event.
sendMove (moveData )
Parameters
moveData - any meta data associated with the move
Returns
void
Sends a start game request to the server. Result of the request is provided in the onGameStarted callback of the TurnBasedRoomListener.
startGame ( )
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
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.
setGeoLocation(location)
Parameters
location - server location. For e.g. US, EU, JAPAN
Returns
void
When the onNextTurnRequest is sent by the server, it sends 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.
setNextTurn(nextTurn)
Parameters
nextTurn - the string value for the next turn
Returns
void
sendPrivateUpdatePeers(to,bytes);
Parameters
to - to username
bytes - update message
Returns
void
getOnlineUsersCount();
Parameters
Returns
void
getAllRoomsCount();
Parameters
Returns
void
joinAndSubscribeRoom(roomId);
Parameters
roomId - Id of the room to be join and subscribed
Returns
void
leaveAndUnsubscribeRoom(roomId);
Parameters
roomId - Id of the room to be subscribed
Returns
void
getRoomInRangeWithProp(minJoinedUsers,maxJoinedUsers,properties);
Parameters
minJoinedUsers- minimum number of users in room to be joined
maxJoinedUsers- maximum number of users in room to be joined
properties- properties of the room to be joined
Returns
void
getUserStatus(username);
Parameters
username - Username of the player
Returns
sendChat(message,saveHistory,roomId);
Parameters
message - message to be sent
saveHistory - Boolean variable indicating sent message needs to be saved or not.
roomId - Id of the room
Returns
setDbName(dbName);
1.Login to AppHQ Management Console.
2.Select App42 Cloud API from the product drop down.
3.Select Storage from left most menu.
4.Select JSON from the sub menu and click on Add DB button.
5.Provide the DBName and click on Submit button
Parameters
dbName - Database name that will be set for the chat history.
Returns
enableChatHistory(saveHistory);
Parameters
saveHistory - If true, the client can save chat using sendChat API
Returns
getChatHistory(roomId,max,offset);
Parameters
roomId- Id of the room whose history is requested
max- Number of messages to be fetched from the server
offset- index from where the messages need to be fetched
Returns