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

Flash Getting Started

WarpClient provides an interface for applications to interact with the cloud services. It allows client side applications to connect, subscribe and manage server side rooms, lobbies and users. The APIs are developed to be used asynchronously, which means you simply add the corresponding request listeners to the WarpClient instance to receive responses and updates. This page describes to how to set up your connection with the cloud server and introduces API usage.

Important You must have imported the SWC of AppWARP SDK to use the AppWarp API’s. In Flash Builder you can do so by ‘Adding SWC’ in Library Path section of ActionScript Build Path settings in your project’s properties

AS3 API Reference

In order to use the various functions available, you will have to initialize and connect the instance of WarpClient. WarpClient is initialized by passing the apiKey and secretKey which you received after creating an app from AppHq (App42 management console).

WarpClient.initialize("Your API Key", "Your Secret Key"); 

After initialization, it is recommended that you implement and set a request listeners which will be called by WarpClient with the result of the requests. WarpClient comprises different listeners for different type of requests namely

  • Connection Request Listener
  • Lobby Request Listener
  • Zone Request Listener
  • Room Request Listener
  • Notification Listener
var appwarp:WarpClient;
WarpClient.initialize("Your API Key", "Your Secret Key"); 
appwarp =  WarpClient.getInstance();

The connection request listener callback will be invoked once the connection with the Warp server has been established with the given username. If this is successful, you can go ahead and call the room/lobby APIs of your app zone. Note that two users can not be connected to the online application simultaneously. Here is a simple implementation of a request listener.

class connectionListener implements ConnectionRequestListener
	public function onConnectDone(res:int):void;
	public function onDisConnectDone(res:int):void;
setZoneRequestListener : Set your listener object on which callbacks will be invoked when a response from the server is received for Zone level requests like create/deleteRoom, User requests etc.
public function setZoneRequestListener(listner:ZoneRequestListener):void;

setRoomRequestListener : Set your listener object on which callbacks will be invoked when a response from the server is received for Room requests like join/leaveRoom, subscribe/unsubscribeRoom and getLiveRoomInfo

public function setRoomRequestListener(listener:RoomRequestListener):void;

setLobbyRequestListener : Set your listener object on which callbacks will be invoked when a response from the server is received for Lobby requests like join/leaveLobby, subscribe/unsubscribeLobby and getLiveLobbyInfo.

public function setLobbyRequestListener(listener:LobbyRequestListener):void;

setNotificationRequestListener : Set your listener object on which callbacks will be invoked when a notification is received from the server for any resource that has been subscribed to.

public function setNotificationListener(listener:NotificationListener):void;

Result Codes : These can be retrieved when an event callback is invoked from the event instance.

public class ResultCode
	public static const success:int = 0;
	public static const auth_error:int = 1;
	public static const resource_not_found:int = 2;
	public static const resource_moved:int = 3;
	public static const bad_request:int = 4;	
	public static const connection_error:int = 5;	
	public static const unknown_error:int = 6;
	public static const size_error:int = 7;
	public static const api_not_found:int = 8;

Appwarp also allows you to set custom data for users and rooms through the methods setCustomUserData() and setCustomRoomData(). To retrieve the custom data and other information WarpClient comprises getLiveUserInfo() and getLiveRoomInfo() methods.