Java 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.

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 add 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

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.

addZoneRequestListener : Add 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 void addZoneRequestListener(ZoneRequestListener listener)

addRoomRequestListener : add 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 void addRoomRequestListener(RoomRequestListener listener)

addLobbyRequestListener : add 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 void addLobbyRequestListener(LobbyRequestListener listener)

addNotificationRequestListener : add 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 void addNotificationListener(NotifyListener listener)

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

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.