C# 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, you are ready to connect and authenticate with your application on the server. It is recommended you implement and add a connection request listener which will be called by WarpClient with the result of the connection and authentication requests.

The connection request listener callback will be invoked once the connection with the Warp server has been established. If this is successful,you can go ahead and call the authenticate API by giving in the user name with which the client wishes to join the online application. Note that two users with the same name can not be connected to the online application simultaneously. Here is a simple implementation of a request listener.

Once you have successfully connected 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.

myGame.JoinRoom(roomId);
myGame.SubscribeRoom(roomID);

To exchanges messages you can either send messages in plain text format using sendChat() method or send messages in binary format using sendUpdate() method respectively. To catch the messages send through sendChat() method use the onChatReceived() method of MyNotificationListener and to catch the messages send through onUpdatePeersReceived() method of MyNotificationListener.

myGame.SendChat(message);

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.