marmalade-usage-guide

Marmalade Icon marmalade usage guide

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

Marmalade 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).

AppWarp::Client::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
AppWarp::Client* WarpClientRef;
AppWarp::Client::initialize("Your API Key", "Your Secret Key");
WarpClientRef = AppWarp::Client::getInstance();
WarpClientRef->setConnectionRequestListener(&listener);

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 Listener : public AppWarp::ConnectionRequestListener
{
public:
	void onConnectDone(int);
	void onDisConnectDone(int);
};
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.
void setZoneRequestListener(ZoneRequestListener *listner);

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

void setRoomRequestListener(RoomRequestListener *listener);

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.

void setLobbyRequestListener(LobbyRequestListener *listener);

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.

void setNotificationListener(NotificationListener *listener);

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

  AppWarp::ResultCode::success = 0;
  AppWarp::ResultCode::auth_error = 1;
  AppWarp::ResultCode::resource_not_found = 2;
  AppWarp::ResultCode::resource_moved = 3;
  AppWarp::ResultCode::bad_request = 4;
  AppWarp::ResultCode::connection_error = 5;
  AppWarp::ResultCode::unknown_error = 6;
  AppWarp::ResultCode::size_error = 7;
  AppWarp::ResultCode::api_not_found = 8;