csharp-api-reference

*We assure you that we do not spam. You may receive occasional emails from us.
 You can always unsubscribe.
cSharp

C# Client APIs

Initialize
Initializes the singleton instance of WarpClient with the developer credentials. This has to be called only once during the lifetime of the application. It is required before you can call any other API.
  public static void Initialize(String apiKey, String privateKey)  
                          OR 
  public static byte initialize(String apiKey, String privateKey, String hostName)
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.
hostName - AppWarp Server IP Or Name.
Returns void
Set Recovery Allowance
Sets the time allowed for the client to recover from an intermittent connection loss. This must be set before the initial connect API is called as that associates the value on the server for the given connection.
public void setRecoveryAllowance(int maxRecoveryTime)
Parameters maxRecoveryTime - time - the time (in seconds) allowed to the client to recover from intermittent connection loss Returns void
Recover Connection
Attempts to recover from an intermittent connection error. If successful, the client will be placed in the same room as before the loss and all its subscriptions will be maintained. The other subscribed users of the room, will receive onUserResumed notification. This can only be called if an established session was lost due to a connectivity error and the client got onConnectDone with a recoverable connection error code. The connection must be restored within the recovery allowance period, after which the server considers the session to be over (non-recoverable).
public void RecoverConnection()
Parameters None Returns void
Recover Connection With SessionID
Attempts to recover from an intermittent connection error.Since this API requires sessionId so it has to be saved by the game on the last successful connection.The other subscribed users of the room, will receive onUserResumed notification.The connection must be restored within the recovery allowance period, after which the server considers the session to be over (non-recoverable).
public void RecoverConnectionWithSessionID(int sessionId,string userName)
Parameters sessionId - sessionId of the last successful session userName - name of the player Returns void
Connect
Sets up your connection with the AppWarp cloud server. The username passed in this method must be unique across all other concurrently connected users. If two users with the same name try to connect at the same time, then the first one will win and the second one will get an error. The username string parameter length must be more than 0 and less than 48. Also it shouldn’t contain the following characters “, ; / \”. The result of the operation is provided in the onConnectDone callback of the Connection Request Listener.
  public void Connect(String userName)
Parameters username - name of the player Returns void
Disconnect
Disconnects the connection with the AppWarp server. The result for this request will be provided in the onDisConnectDone callback of the Connection Request Listener.
  public void Disconnect()
Parameters None Returns void
Get Connection State
Queries the connection state of the client with the server. The values returned are according to the following :
byte CONNECTED = 0;
byte CONNECTING = 1;
byte DISCONNECTED = 2;
byte DISCONNECTING = 3;
byte RECOVERING = 4;
  public byte GetConnectionState()
Parameters None Returns byte - WarpConnectionState
Join Lobby
Sends a join lobby request to the server. Result of the request is provided in the onJoinLobbyDone callback of the registered LobbyRequestListener objects.
  public void JoinLobby()
Parameters None Returns void
Leave Lobby
Sends a leave lobby request to the server. Result of the request is provided in the onLeaveLobbyDone callback of the registered LobbyRequestListener objects.
  public void LeaveLobby()
Parameters None Returns void
Subscribe Lobby
Sends a subscribe lobby request to the server. Result of the request is provided in the onSubscribeLobbyDone callback of the registered LobbyRequestListener objects. Users who have subscribed to the lobby receive chat events from other users in the lobby as well as join/leave notifications about all players to and from the lobby as well as all the rooms. In addition, lobby subscribers get notifications when a new room is created or deleted. All these notification events are given in the registered NotifyListener objects.
  public void SubscribeLobby()
Parameters None Returns void
UnSubscribe Lobby
Sends an unsubscribe lobby request to the server. Result of the request is provided in the onUnsubscribeLobbyDone callback of the LobbyRequestListener.
  public void UnsubscribeLobby()
Parameters None Returns void
Join Room
Sends a join room request to the server. Result of the request is provided in the onJoinRoomDone callback of the registered RoomRequestListener objects. A user can only be joined to one location (room or lobby) at a time. If a user joins a room, it will automatically be removed from its current location.
  public void JoinRoom(String roomId)
Parameters roomId - Id of the room to be joined Returns void
Join Room In Range
Sends a join room request to the server with the given range of joined users. Result of the request is provided in the onJoinRoomDone callback of the registered RoomRequestListener objects. A user can only be joined to one location (room or lobby) at a time. If a user joins a room, it will automatically be removed from its current location. This enables developers to easily add quick-play scenarios.
  public void JoinRoomInRange(int minUserCount, int maxUserCount, bool maxPreferred)
Parameters minUserCount - minimum users in the room maxUserCount - maximum users in the room maxPreferred - number of users preferred for joining a room Returns void
Get Rooms In Range
Sends a request to the server to fetch a list of rooms with the given range of joined users. Result of the request is provided in the onGetMatchedRoomsDone callback of the registered ZoneRequestListener objects.
  public void GetRoomsInRange(int minUserCount, int maxUserCount)
Parameters minUserCount - minimum users in the room maxUserCount - maximum users in the room Returns void
Join Room With Properties
Sends a join room request to the server with the condition that the room must have a matching set of property-value pairs associated with it. This is useful in match-making. Result of the request is provided in the onJoinRoomDone callback of the registered RoomRequestListener objects.
  public void JoinRoomWithProperties(Dictionary<String, Object> tableProperties)
Parameters tableProperties- properties of the room to be joined Returns void
Leave Room
Sends a leave room request to the server. Result of the request is provided in the onLeaveRoomDone callback of the registered RoomRequestListener objects.
  public void LeaveRoom(String roomId)
Parameters roomId - Id of the room to be left Returns void
Create Room
Sends a create 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 room at the server. This room’s lifetime is limited to the time the users are inside it. Read more about Rooms here.
  public void CreateRoom(String name, String owner, int maxUsers, Dictionary<String, Object> tableProperties)
                                                                  OR
  public void CreateRoom(String name, String owner, int maxUsers, Dictionary<String, Object> tableProperties, int cleanupTime)
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)
cleanupTime - seconds after which the room is deleted if it remains empty (between 0 and 3600)
Returns void
Create Turn Based Room
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. This room’s lifetime is limited to the time the users are inside it. Read more about Rooms here.
  public void CreateTurnRoom(String name, String owner, int maxUsers, Dictionary<String, Object> tableProperties, int turnTime)
                                                               OR
  public void CreateTurnRoom(String name, String owner, int maxUsers, Dictionary<String, Object> tableProperties, int turnTime, int cleanupTime)
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.
cleanupTime - seconds after which the room is deleted if it remains empty (between 0 and 3600)
Returns void
Send Move
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 Turn Based Room Listener objects. If the joined user is not in turn based room or if its 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.
  public void sendMove(String moveData, String nextTurn="")
Parameters
moveData - any meta data associated with the move
nextTurn - an empty string value for the next turn
Returns void
Delete Room
Sends a delete room request to the server. Result of the request is provided in the onDeleteRoomDone callback of the registered ZoneRequestListener objects. Only dynamic rooms can be deleted through this API. Static rooms (created from AppHQ) can not be deleted through this. Read more about Rooms here.
  public void DeleteRoom(String roomId)
Parameters roomId - Id of the room to be deleted Returns void
Subscribe Room
Sends a subscribe room request to the server. Result of the request is provided in the onSubscribeRoomDone callback of the registered RoomRequestListener objects. Once subscribed, the client will receive all notifications from the room such as chat, update and property changed events. In addition, the client will also receive notifications when a user joins or leaves the subscribed room. These notifications are given in the registered NotifyListener objects.
  public void SubscribeRoom(String roomId)
Parameters roomId - Id of the room to be subscribed Returns void
UnSubscribe Room
Sends a unsubscribe room request to the server. Result of the request is provided in the onUnSubscribeRoomDone callback of the registered RoomRequestListener objects.
  public void UnSubscribeRoom(String roomId)
Parameters roomId - Id of the room to be unsubscribed Returns void
Send Chat
Sends a chat message to the room (or lobby) to which the user is currently joined. Result of the request is provided in the onSendChatDone callback of the registered ChatRequestListener objects. The length of the message string must not exceed 1000. All the users who are subscribed to the location in which the message is sent will get an onChatReceived event on their registered NotifyListener objects.
  public void SendChat(String message)
Parameters message - message to be sent Returns void
Send Private Chat
Sends a private message to the given user if it’s 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 an onPrivateChatReceived event on its registered NotifyListener objects.
  public void sendPrivateChat(String username, String message)
Parameters username - recipient of the message message - message to be sent Returns void
Send Update Peers
Sends a byte array update message to the room to which the user is currently joined. Result of the request is provided in the onSendUpdateDone callback of the registered UpdateRequestListener objects. All users who are subscribed to the room to which the update is sent will get an onUpdatePeersReceived event on their registered NotifyListener objects. This is useful if developers want to send their own binary encoded data across and is useful in minimizing the payload exchanged between the clients and AppWarp cloud server. The frequency at which these messages can be processed is not restricted by the server. However, the latency involved is largely determined by the client’s bandwidth. The size of the byte array must not exceed 1000. The corresponding UDP flavor of this API is sendUdpUpdatePeers, which is unreliable and may not work over cellular data connections – hence no result callback should be expected from it. The behavior is otherwise similar.
  public void SendUpdatePeers(byte[] update)
Parameters update - byte array data to be sent Returns void
Send Private Update
Sends a byte array update message to the recipient user. Result of the request is provided in the onSendPrivateUpdateDone callback of the registered UpdateRequestListener objects. Remote user will get an onPrivateUpdateReceived event on their registered NotifyListener objects. This is useful if developers want to send private data between the users. The corresponding UDP flavor of this API is sendUDPPrivateUpdate, which is unreliable and may not work over cellular data connections – hence no result callback should be expected from it. The behavior is otherwise similar.
  public void sendPrivateUpdate(String toUsername,byte[] update)
Parameters toUsername - recipient username update - byte array data to be sent Returns void
Get Live Room Info
Retrieves the live information of the given room from the server. Result is provided in the onGetLiveRoomInfoDone callback of the registered RoomRequestListener objects. The information includes the names of the currently joined users, the room’s properties and any associated custom Data. This is useful in getting a snapshot of a room’s state.
  public void GetLiveRoomInfo(String roomId)
Parameters roomId - Id of the room Returns void
Get Live User Info
Retrieves the live information of the user from the server. Result is provided in the onGetLiveUserInfo callback of the registered ZoneRequestListener objects. The information (if user is online) includes the current location of the user and any associated custom data. It is useful in building scenarios where you want to find if a user’s friends are online and then join their room if found online.
  public void GetLiveUserInfo(String username)
Parameters username - user whose information is requested Returns void
Get Live Lobby Info
Retrieves live information of the lobby from the server. Result is provided in the onGetLiveLobbyInfo callback of the registered LobbyRequestListener objects. The information returned includes the names of the users who are currently joined to the lobby.
  public void GetLiveLobbyInfo()
Parameters None Returns void
Set Custom User Data
Updates the custom data associated with the given user on the server (if the given user is online). Result is provided in the onSetCustomUserDataDone callback of the registered ZoneRequestListener objects. It can be useful in setting status messages or avatar URLs etc for online users.
  public void SetCustomUserData(String userName, String customData)
Parameters
userName - user for whom custom data has to be updated
customData - custom data that will be set for the user
Returns void
Set Custom Room Data
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 to use the room’s properties wherever possible. Use this when you need to associate data with a room which can not be represented as key-value pairs.
  public void SetCustomRoomData(String roomId, String customRoomData)
Parameters
roomId - Id of the room
customRoomData - custom data that will be set for the room
Returns void
Update Room Properties
Updates the properties associated with the given room on the server. Result is provided in the onUpdatePropertyDone callback of the registered RoomRequestListener objects. Properties which are not found on the server, will be added while properties which are already present will simply be updated with the new values. You can also specify the list of properties that you want to remove from the room. 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.
  public void UpdateRoomProperties(String roomID, Dictionary<String, Object> tableProperties, List<String> removeList)
Parameters
roomId - Id of the room
tableProperties- Properties of the room to be added or updated.
removeList - List of properties to be removed.
Returns void
Lock Properties
Locks the given room properties associated with the currently joined room on the server. Result is provided in the onLockPropertiesDone callback of the registered RoomRequestListener objects. If any property is currently locked by another user, this request will fail. 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.
  public void LockProperties(Dictionary<String, Object> lockedProperties)
Parameters
lockedProperties - dictionary of keys and their values to be locked for the user
Returns void
Unlock Properties
Unlocks the given room properties associated with the currently joined room on the server. Result is provided in the onUnlockPropertiesDone callback of the registered RoomRequestListener objects. If any property is currently unlocked, this request will give BAD_REQUEST. 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.
  public void UnlockProperties(List<String> properties)
Parameters
properties - list of keys to be unlocked for the user
Returns void
Get Online Users
Retrieves usernames of all the users connected (online) to the server. Result is provided in the onGetOnlineUsersDone callback of the registered ZoneRequestListener objects.
  public void GetOnlineUsers()
Parameters None Returns void
Get All Rooms
Retrieves the room ids of all the rooms on the server. Result is provided in the onGetAllRoomsDone callback of the registered ZoneRequestListener objects. To get a filtered list of rooms, use the GetRoomWithProperties API.
  public void GetAllRooms()
Parameters None Returns void
Get Room With Properties
Retrieves information of the room that contains properties which match with the given properties. Result is provided in the onGetMatchedRoomsDone callback of the registered ZoneRequestListener objects. This is useful in building a filtered list of rooms.
  public void GetRoomWithProperties(Dictionary<String, Object> properties)
Parameters properties- Properties of the room to be matched Returns void
Add Connection Request Listener
Adds (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 Connect and Disconnect APIs. The object must implement the ConnectionRequestListener interface.
  public void AddConnectionRequestListener(ConnectionRequestListener listner)
Parameters listener - listener object Returns void
Add Room Request Listener
Adds (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 requests pertaining to a room. The object must implement the RoomRequestListener interface.
  public void AddRoomRequestListener(RoomRequestListener listner)
Parameters listener - listener object Returns void
Add Zone Request Listener
Adds (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 zone level requests such as create/delete room or live user info requests. The object must implement the ZoneRequestListener interface.
  public void AddZoneRequestListener(ZoneRequestListener listner)
Parameters listener - listener object Returns void
Add Lobby Request Listener
Adds (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 lobby level requests. The object must implement the Lobby Request Listener interface.
  public void AddLobbyRequestListener(LobbyRequestListener listner)
Parameters listener - listener object Returns void
Add Notification Listener
Adds (registers) the given listener object to the list of objects on which callbacks will be invoked when a notification is received from the server from any subscribed location (room or lobby). The object must implement the NotifyListener interface.
  public void AddNotificationListener(NotifyListener listner)
Parameters listener - listener object Returns void
Add Update Request Listener
Adds (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 or SendPrivateUpdate request. The object must implement the UpdateRequestListener interface.
  public void AddUpdateRequestListener(UpdateRequestListener listener)
Parameters listener - listener object Returns void
Add Chat Request Listener
Adds (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 or sendPrivateChat request. The object must implement the ChatRequestListener interface.
  public void AddChatRequestListener(ChatRequestListenerlistener listener)
Parameters listener - listener object Returns void
Add Turn Based Room Request Listener
Adds (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 turn based game move request. The object must implement the Turn Based Room Listener interface.
  public void AddTurnBasedRoomRequestListener(TurnBasedRoomListener listener)
Parameters listener - listener object Returns void
Start Game
Sends a start game request to the server in TurnBasedRoom. Result of this request is provided in onStartGameDone callback of the registered TurnBasedRoomListener objects. If successful game will be started in TurnBasedRoom.
 public void  startGame(bool isDefaultLogic=true, String nextTurn="")
Parameters isDefaultLogic - a true boolean value nextTurn - an empty string for next turn Returns void
Stop Game
Sends a stop game request to the server in TurnBasedRoom. Result of this callback is provided in onStopGameDone callback of the registered TurnBasedRoomListener objects. If successful game will be stopped in TurnBasedRoom.
 public void  stopGame()
Parameters None Returns void
Get Move History
Sends get move history request to the server in TurnBasedRoom. Result of this callback is provided in onGetMoveHistoryDone callback of the registered TurnBasedRoomListener objects.
 public void  getMoveHistory()
Parameters None Returns void
setGeo
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(String geo)
Parameters geo - server location. For e.g. us, eu, japan Returns void
GetSessionId
It gives sessionId of the current established connection,otherwise returns zero.
 public int GetSessionId()
Parameters None Returns int - sessionId
GetInstance
It returns the singleton instance of WarpClient.This should be initialized with a key pair before it is used.
 public static WarpClient GetInstance()
Parameters None Returns WarpClient - singleton instance of WarpClient.
GetApiKey
It gives the Api Key of the current established connection,otherwise returns null.
 public String GetApiKey()
Parameters None Returns String - Api key
GetPrivateKey
It gives the Private/Secret Key of the current established connection,otherwise returns null.
 public String GetPrivateKey()
Parameters None Returns String - Private/Secret key
Remove Connection Request Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a response from the server is received for Connect and Disconnect APIs. The object must implement the ConnectionRequestListener interface.
  public void RemoveConnectionRequestListener(ConnectionRequestListener listener)
Parameters listener - listener object Returns void
Remove Zone Request Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a response from the server is received for zone level requests such as create/delete room or live user info requests. The object must implement the ZoneRequestListener interface.
  public void RemoveZoneRequestListener(ZoneRequestListener listener)
Parameters listener - listener object Returns void
Remove Lobby Request Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a response from the server is received for lobby level requests. The object must implement the Lobby Request Listener interface.
  public void RemoveLobbyRequestListener(LobbyRequestListener listener)
Parameters listener - listener object Returns void
Remove Room Request Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a response from the server is received for requests pertaining to a room. The object must implement the RoomRequestListener interface.
  public void RemoveRoomRequestListener(RoomRequestListener listner)
Parameters listener - listener object Returns void
Remove Chat Request Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a response from the server is received for a SendChat or sendPrivateChat request. The object must implement the ChatRequestListener interface.
  public void RemoveChatRequestListener(ChatRequestListenerlistener listener)
Parameters listener - listener object Returns void
Remove Turn Based Room Request Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a response from the server is received for a turn based game move request. The object must implement the Turn Based Room Listener interface.
  public void RemoveTurnBasedRoomRequestListener(TurnBasedRoomListener listener)
Parameters listener - listener object Returns void
Remove Update Request Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a response from the server is received for a SendUpdatePeers or SendPrivateUpdate request. The object must implement the UpdateRequestListener interface.
  public void RemoveUpdateRequestListener(UpdateRequestListener listener)
Parameters listener - listener object Returns void
Remove Notification Listener
Removes the given listener object from the list of objects on which callbacks will be invoked when a notification is received from the server from any subscribed location (room or lobby). The object must implement the NotifyListener interface.
  public void RemoveNotificationListener(NotifyListener listner)
Parameters listener - listener object Returns void
Send UDP Private Update
Sends a byte array update message to the recipient user. This is useful if developers want to send private data between the users. It is unreliable and may not work over cellular data connections – hence no result callback should be expected from it. The corresponding flavor of this API is sendPrivateUpdate which shows a similar behavior.
  public void sendUDPPrivateUpdate(String toUsername,byte[] update)
Parameters toUsername - recipient username update - byte array data to be sent Returns void
Send UDP Update Peers
Sends a byte array update message to the room to which the user is currently joined. This is useful if developers want to send their own binary encoded data across and is useful in minimizing the payload exchanged between the clients and AppWarp cloud server. The frequency at which these messages can be processed is not restricted by the server. However, the latency involved is largely determined by the client’s bandwidth. The size of the byte array must not exceed 1000. It is unreliable and may not work over cellular data connections – hence no result callback should be expected from it.The corresponding UDP flavor of this API is sendUpdatePeers which shows a similar behavior.
  public void SendUDPUpdatePeers(byte[] update)
Parameters update - byte array data to be sent Returns void
Init UDP
If the user is connected, it sends an associated UDP Port message to the room (or lobby) to which the user is currently joined. It is unreliable and may not work over cellular data connections – hence no result callback should be expected from it.
  public void initUDP()
Parameters None Returns void
Set Next Turn
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.
  public void SetNextTurn(String nextTurn)
Parameters nextTurn - the string value for the next turn Returns void