You are on page 1of 2

Objective C Getting Started

How to get your API and Secret Key


Read AppWarp Concepts
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.
Complete 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).
view plaincopy to clipboardprint?
1. [WarpClient initWarp:@"Your api key" secretKey:@"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
Connection Request Listener
Lobby Request Listener
Zone Request Listener
Room Request Listener
Chat Request Listener
Update Request Listener
Notification Listener
view plaincopy to clipboardprint?
1. WarpClient *warpClient = [WarpClient getInstance];
2. [warpClient addConnectionRequestListener:connectionListener];
3. [warpClient addZoneRequestListener:connectionListener];
4. [warpClient addRoomRequestListener:roomListener];
5. [warpClient addNotificationListener:notificationListener];
The connection request listener callback will be invoked once the connection with the Warp
server has been established. Note that two users can not be connected to the online
application simultaneously. Here is a simple implementation of a request listener
view plaincopy to clipboardprint?
1. #import < Foundation/Foundation.h >
2. @interface ConnectionListener : NSObject < ConnectionRequestListener >
3. @end
4. #import "ConnectionListener.h"
5. @implementation ConnectionListener
6. -(void)onConnectDone:(ConnectEvent*) event
7. {
8. if (event.result==0)

9. {
10.
NSLog(@"connection success");
11.
[[WarpClient getInstance] joinRoom:@"RoomId"];
12.
}
13.
else
14.
{
15.
NSLog(@"connection failed");
16.
}
17.
}
18.
-(void)onDisconnectDone:(ConnectEvent*) event
19.
{
20.
NSLog(@"On Disconnect invoked");
21.
}
Once you have supplied all the listeners you have to call the connectWithUserName() method
of WarpClient to connect to the AppWarp server and join the Zone by giving in the user name
as a parameter with which the client wishes to join the online application.
view plaincopy to clipboardprint?
1. [[WarpClient getInstance] connectWithUserName:@"Jonny"];

Once you have successfully joined, you can either join the lobby or join a particular room. You
should also subscribe the lobby or the room joined to catch the notifications generated in that
particular room or lobby
view plaincopy to clipboardprint?
1. [[WarpClient getInstance] joinRoom:@"RoomId"];
2. [[WarpClient getInstance]subscribeRoom:@"RoomId"];
To exchanges messages you can either send messages in plain text format
using sendChat method or send encrypted data using sendUpdatePeers method respectively.
To catch the messages sent through sendChat method, use the onChatReceived method of
MyNotificationListener and to catch the data sent through sendUpdatePeers method, use
the onUpdatePeersReceived method of MyNotificationListener.
Appwarp also allows you to set custom data for users and rooms through the
methods setCustomUserData andsetCustomRoomData. To retrieve the custom data
and other information WarpClient
comprises getLiveUserInfoand getLiveRoomInfo methods.

You might also like