as3-client-apis

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

Flash Client APIs

Initialize
public static function initialize(apiKey:String, secretKey:String):void;
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.

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

Get Instance
public static function getInstance():WarpClient
Gets the Singleton instance of WarpClient

Parameters

Returns

void

Connect
public function connect(username:String):void;
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 last one will win and the older one will get disconnected. The result of the operation is provided in the onConnectDone callback of the ConnectionRequestListener.

Parameters

username - Username of the player

Returns

void

Disconnect
public function disconnect():void;
Disconnects the connection with the AppWarp server. The result for this request will be provided in the onDisConnectDone callback of the ConnectionRequestListener

Parameters

Returns

void

Join Lobby
public function joinLobby():void;
Sends a join lobby request to the server. Result of the request is provided in the onJoinLobbyDone callback of the registered LobbyRequestListener objects.

Parameters

Returns

void

Leave Lobby
public function leaveLobby():void;
Sends a leave lobby request to the server. Result of the request is provided in the onLeaveLobbyDone callback of the registered LobbyRequestListener objects.

Parameters

Returns

void

Subscribe Lobby
public function subscribeLobby():void;
Sends a subscribe lobby request to the server. Result of the request is provided in the onSubscribeLobbyDone callback of the registered LobbyRequestListener objects. Users which 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 fro the lobby and 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.

Parameters

Returns

void

Unsubscribe Lobby
public function unsubscribeLobby():void;
Sends a unsubscribe lobby request to the server. Result of the request is provided in the onUnsubscribeLobbyDone callback of the LobbyRequestListener.

Parameters

Returns

void

Join Room
public function joinRoom(roomId:String):void;
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 in one location (room or lobby) at a time. If a user joins a room, it will automatically be removed from its current location.

Parameters

roomId - Id of the room to be joined

Returns

void

Join Room In Range
public function joinRoomInRange(minUsers:int, maxUsers:int, maxPreferred:Boolean):void
Sends a join room request to the server with the condition that the room must have at least minUsers and at Most maxUsers. Result of the request is provided in the onJoinRoomDone callback of the registered RoomRequestListener. This is useful is supporting quick play modes.

Parameters

minUsers- number of minimum users in room to be joined

maxUsers- number of maximum users in room to be joined

maxPreferred- flag to specify search priority for room to be joined

Returns

void

Join Room With Properties
public function joinRoomWithProperties(tableProperties:Object):void;
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.

Parameters

tableProperties- properties of the room to be joined

Returns

void

Leave Room
public function leaveRoom(roomId:String):void;
Sends a leave room request to the server. Result of the request is provided in the onLeaveRoomDone callback of the registered RoomRequestListener.

Parameters

roomId - Id of the room to be left

Returns

void

init UDP
public function initUDP():void;
Initializes the UDP connection with the server. This must be called once after the client is successfully connected with the server (connect API) and before you can use the sendUdpUpdate API. Note that this will throw VerifyError when running in the browser as only desktop, android and iOS AIR Runtimes support datagram sockets.

Parameters

Returns

void

set recovery allowance
public static function setrecoveryallowance(time:int):void;
Sets the time allowed to 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.

Parameters

time - the time (in seconds) allowed to the client to recover from intermittent connection loss

Returns

void

recover connection
public function recoverConnection():void;
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).

Parameters

Returns

void

Create Room
public function createRoom(name:String, owner:String, maxUsers:int, tableProperties:Object):void;
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. These rooms lifetime is limited till the time users are inside it. Read more about Rooms here.

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

Create Turn Room
public function createTurnRoom(name:String, owner:String, maxUsers:int, tableProperties:Object, turnTime:int):void;
Sends a create turnbased room request to the server with the given meta data and turn time. 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.

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)
turnTime - the time (seconds) given for each turn

Returns

void

Delete Room
public function deleteRoom(roomId:String):void;
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.

Parameters

roomId - Id of the room to be deleted

Returns

void

Subscribe Room
public function subscribeRoom(roomId:String):void;
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 change 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.

Parameters

roomId - Id of the room to be subscribed

Returns

‘void’

Unsubscribe Room
public function unsubscribeRoom(roomId:String):void;
Sends a unsubscribe room request to the server. Result of the request is provided in the onUnSubscribeRoomDone callback of the registered RoomRequestListener objects.

Parameters

roomId - Id of the room to be subscribed

Returns

void

Send Chat
public function sendChat(message:String):void;
Sends a chat message to the room (or lobby) in which the user is currently joined. Result of the request is provided in the onSendChatDone callback of the registered ChatRequestListener objects. All users who are subscribed to the location in which the message is sent will get a onChatReceived event on their registered NotifyListener objects.

Parameters

message - message to be send

Returns

void

Send Update
public function sendUpdate(update:ByteArray):void;
Sends a byte array update message to room in 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 in which the update is sent will get a 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 and location with respect to the cloud server.

Parameters

update - binary data to be send

Returns

void

Send UDP Update
public function sendUdpUpdate(update:ByteArray):void;
Sends over UDP a byte array update message to room in which the user is currently joined. Since UDP is unreliable, no response callback is given for this request. All users who are subscribed to the room in which the update is sent will get a 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 and the location with respect to the cloud server. Before using this, you must call initUDP API.

Parameters

update - binary data to be send

Returns

void

Get Live Room Info
public function getLiveRoomInfo(roomId:String):void;
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 rooms properties and any associated customData. This is useful in getting a snapshot of a rooms state.

Parameters

roomId - Id of the room

Returns

void

Get Live User Info
public function getLiveUserInfo(username:String):void;
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 users friends are online or not and then join their room if found online.

Parameters

username - user who's information is requested

Returns

void

Get Live Lobby Info
public function getLiveLobbyInfo():void;
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 in the lobby.

Parameters

Returns

void

Set Custom User Data
public function setCustomUserData(userName:String, customData:String):void;
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 url’s etc for online users.

Parameters

userName - user for whom custom data has to be update
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 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.

public function SetCustomRoomData(roomId:String, customRoomData:String):void;

Parameters

roomId - Id of the room
customRoomData - custom data that will be set for the room

Returns

void

Update Room Properties
public function updateRoomProperties(roomID:String, tableProperties:Object, removeArray:Array);
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 remove. 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

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

Get Online Users
public function getOnlineUsers():void;
Retrieves usernames of all the users connected (online) to the server. Result is provided in the onGetOnlineUsers callback of the registered ZoneRequestListener objects.

Parameters

Returns

void

Get All Rooms
public function getAllRooms():void;
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 GetRoomInRange or GetRoomWithProperties APIs.

Parameters

Returns

void

Get Room In Range
public function getRoomsInRange(minUsers:int, maxUsers:int):void
Retrieves information of the rooms that contain at least minUsers and at most maxUsers in them. Result is provided in the onGetMatchedRoomsDone callback of the registered ZoneRequestListener objects. This is useful in building a filtered list of rooms.

Parameters

minUsers- number of minimun users in room to be joined

maxUsers- number of maximum users in room to be joined

Returns

void

Get Room With Properties
public function getRoomWithProperties(properties:Object):void;
Retrieves information of the room that contain 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.

Parameters

properties- properties of the room to be joined

Returns

void

Set Zone Request Listener
public function setZoneRequestListener(listener:ZoneRequestListener):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 zone level requests such as create/delete room or live user info requests. The object must implement the ZoneRequestListener interface.

Parameters

listener - method for listening to the request

Returns

void

Set Room Request Listener
public function setRoomRequestListener(listener:RoomRequestListener):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 requests pertaining to a room. The object must implement the RoomRequestListener interface.

Parameters

listener - method for listening to the request

Returns

void

Set Lobby Request Listener
public function setLobbyRequestListener(listener:LobbyRequestListener):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 lobby level request. The object must implement the LobbyRequestListener interface.

Parameters

listener - method for listening to the request

Returns

void

Set Notification Listener
public function setNotificationListener(listener:NotificationListener):void;
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.

Parameters

listener - method for listening to the request

Returns

void

Set Connection Request Listener
public function setConnectionRequestListener(listener:ConnectionRequestListener):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 Connect and Disconnect APIs. The object must implement the ConnectionRequestListener interface.

Parameters

listener - method for listening to the request

Returns

void

Set Update Request Listener

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 SendUpdate request. The object must implement the UpdateRequestListener interface.

public function setUpdateRequestListener(listener:UpdateRequestListener):void;

Parameters

listener - listener object

Returns

void

Set Chat Request Listener

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 function setChatRequestListener(listener:ChatRequestListener):void;

Parameters

listener - listener object

Returns

void

Set Turn Based Room Request Listener

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 turn based room requests. The object must implement the TurnBasedRoomListener interface.

public function setTurnBasedRoomRequestListener(listener:TurnBasedRoomListener):void;

Parameters

listener - listener object

Returns

void

Send Move
public function sendMove(moveData:String, nextTurn:String = ""):void
Sends a move message to the turn based room in which the user is currently joined. Result of the request is provided in the onSendMoveDone callback of the registered TurnBasedRoomListener object. All users who are subscribed to the location in which the message is sent will get a onMoveCompleted event on their registered NotifyListener objects.

Parameters

moveData - data associated with the move to be sent

nextTurn - user to get next turn if isDefaultLogic was set false in startGame

Returns

void

Start Game
public function startGame(isDefaultLogic:Boolean = true, firstTurn:String = ""):void
Sends a start game request to the turn based room in which the user is currently joined. Result of the request is provided in the onStartGameDone callback of the registered TurnBasedRoomListener object. If successful, all users who are subscribed to the room in which the message is sent will get a onGameStarted event on their registered NotifyListener objects.

Parameters

isDefaultLogic - If default logic has to be followed

firstTurn - user to get first turn if isDefaultLogic is false

Returns

void

Stop Game
public function stopGame():void;
Sends a stop game request to the turn based room in which the user is currently joined. Result of the request is provided in the onStopGameDone callback of the registered TurnBasedRoomListener object. If successful, all users who are subscribed to the room in which the message is sent will get a onGameStopped event on their registered NotifyListener objects.

Parameters

Returns

void

Get Move History
public function getMoveHistory():void;
Sends a move history fetch request to the turn based room in which the user is currently joined. Result of the request is provided in the onGetMoveHistoryDone callback of the registered TurnBasedRoomListener object. If successful, the event will also contain an array of the last (upto 5) moves in the room.

Parameters

Returns

void

Set Geo

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 static function setGeoLocation(location:String):void

Parameters

location - server location. For e.g. US, EU, JAPAN

Returns

void

Get ConnectionState

getConnectionState allows you to get the current Connection State of WarpClient.

 public function getConnectionState():int

Parameters

Returns

int

Get SessionID

getSessionID returns the SessionID for current connection with AppWarp Server. SessionID is required when calling recoverConnectionWithSessionID.

public function getSessionID():int

Parameters

Returns

int

Recover Connection With SessionID

recoverConnectionWithSessionID allows you to recover a connection when you have session id from previous connection. Username is also required.

public function recoverConnectionWithSessionID(sessionID:int, username:String):void

Parameters

sessionID - session id of the connection to be recoverd

username - user to be recovered

Returns

void

Enable Trace

enableTrace allows you to turn on traces. This is helpful in debugging.

public static function enableTrace(enable:Boolean):void

Parameters

enable - enable traces

Returns

void

Lock Room 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.

public function lockRoomProperties(lockProperties:Object):void

Parameters

lockProperties - properties to be locked

Returns

void

Unlock Room 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.

public function unlockRoomProperties(properties:Array):void

Parameters

properties - properties to be unlocked

Returns

void

Send Private Chat

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.

public function sendPrivateChat(to:String, msg:String):void

Parameters

to - recipient of the message

msg - message to be sent

Returns

void

Send Private Update

Sends a byte array update message to recipient user. Result of the request is provided in the onSendPrivateUpdateDone callback of the registered UpdateRequestListener objects. Remote user will get a 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 function sendPrivateUpdate(to:String, msg:ByteArray):void

Parameters

to - recipient of the message

msg - message to be sent

Returns

void

Send Private UDP 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 function sendUdpPrivateUpdate(to:String,msg:ByteArray):void

Parameters

to - recipient of the message

msg - message to be sent

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 function setNextTurn(nextTurn:String):void

Parameters

nextTurn - recipient of the message

Returns

void