Making Photo Sharing App in Android using App42 backend platform

Share it now

A photo sharing App which enables user to share his personal photographs with another individual/friend can be developed very quickly with App42 backend API. We have developed a sample App with the help of App42 platform that lets the user to share his photographs with others. In the App, one can pick the friend from his Facebook friend list and can share his picture with him.

This App uses Storage, Social and File storage APIs to implement this feature.

Below mentioned are the few easy steps to get started with the sample App:

  1. Register with App42 platform
  2. Create an App once you are on the Quickstart page after registration.
  3. Download the eclipse project from GithHub Repository and import it in eclipse as Android project.
  4. Open Constants.java in sample app and give the value of app42APIkey  and app42SecretKey that you have received in step #2
  5. Download Facebook SDK and add it as a library project in your application
  6. Modify your FB_APP_ID is in Constants.java file .
  7. Build and Run the project

There is a README.txt file present along with sample app that will provide you more insights about the App. If you have any further queries about how to extend it, please feel free to contact us at support@shephertz.com


Share it now
Be a fan!

Making To-do/Event List in HTML5/JQuery using App42 platform

Share it now

Create upcoming events/task/to-do list and share it with your friends using  App42 platform javascript/JQuery backend SDK in just few lines of coding.

Here are the few easy steps to get started

  1.  Register with App42 platform
  2.  Download the sample and start  making your own JQuery/HTML5 App!

Here is the feature list of the sample App:

  1. User Authentication
  2. Creating your To-do/Event List
  3. Sharing your list with Facebook friends
  4. Tagging your to-do or event to geo locations
  5. Removable List Items
  6. Supports all mobile browsers and desktop browsers

It uses User management, Storage and ACL and Social Service to achieve this.


Share it now
Be a fan!

Doing Facebook OAuth with Nokia S40/J2ME devices using App42 Platform

Share it now

Nokia Asha 3101 Doing Facebook OAuth with Nokia S40/J2ME devices using App42 Platform

Nokia S 40 Asha Series

Doing Facbook OAuth on Nokia S40 and J2ME devices is the biggest challenge while creating the social Apps for this platform because of unavailability of the Facebook J2ME SDK and inapp browser limitation of J2ME devices. App42 platform J2ME SDK provides an easiest and quickest way to do seamless Facebook OAuth on J2ME devices without going in to the complexity of underlying protocol.

Here are the few easy steps to do the FB OAuth for these devices.

Canvas URL : https://api.shephertz.com/cloud/1.0/social/facebook/saveFeaturePhoneFBToken?
Secure Canvas URL : https://apps.shephertz.com/socialkeys.php?
  • Also, make sure that sandbox mode is off for your app.
  • Register with App42 platform if not already registered and create an app for you.
  • Download the latest J2ME SDK from our public Git repo
  • Unzip the downloaded file and put App42_J2ME-x.x.x.jar in your project class path.
  • Now you are ready to do Facebook OAuth with just few lines of code as shown below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
ServiceAPI  sp = new ServiceAPI("YOUR_API_KEY","YOUR_SECRET_KEY");
String fbAppId = "YOUR_FB_APPID";
String fbAppSecret = "YOUR_FB_APP_SECRET";
 
String accessToken = null;
String [] appPermissions = new String [] {"publish_stream","friends_online_presence"};
String code = sp.buildSocialService().doFBOAuthAndGetToken(midlet, fbAppId, appPermissions);
//The Above call will open user login OAuth page in browser and will wait till user authorizes the app.
 
accessToken = sp.buildSocialService().getAccessTokenFromCode(code, fbAppId, fbAppSecret);
System.out.println( "  Token : " + accessToken);
Social socialObj = sp.buildSocialService().getFacebookFriendsFromAccessToken(accessToken);
Vector friendList = socialObj.getFriendList();
//This will return Facebook friends of user whose access token was passed.
  • In above snippet doFBOAuthAndGetToken method will do all the trick, it will open FB user OAuth page and will wait till user authorizes the app.
  • Once user does the authorization, user’s acccesscode is redirected to our server and being further received by your app and being returned by this method.
  • Once you have got the acceess code you can make another call getAccessTokenFromCode to get the access token of that user.
  • The whole story ends once you get the access token with you. Now you can call getFacebookFriendsFromAccessToken on our SDK or can directly use facebook graph API for fetching other information of user.

You can use other App42 backend services like Gaming, Storage, File Storage, Messaging, Geo Spatial, Custom Code to make user engaging social app with writing any backend for J2ME/S40 devices. Start making beautiful Apps with App42 Cloud API S40 SDK. Here is the Sample Code to get you started.




fa3935b8 11e5 41c8 b56e 2f523cb5f9f9 Doing Facebook OAuth with Nokia S40/J2ME devices using App42 Platform






8931e3f4 f630 47a3 9675 fa5b55cf7e24 Doing Facebook OAuth with Nokia S40/J2ME devices using App42 Platform




Share it now
Be a fan!

Make Real-time multiplayer games using Unity3D

Share it now

unity logo Make Real time multiplayer games using Unity3Dappwarp Make Real time multiplayer games using Unity3DUnity3D is a popular cross-platform game engine for building sophisticated 3D games. Using AppWarp, developers can now add realtime communication in their Unity3D games to build beautiful, rich and engaging multiplayer games. The great thing is that developers can do this without any server side code or socket level programming as all the communication is managed by AppWarp SDK and cloud.

To help you get started, we have created a sample project that illustrates how to get the pieces together and set up the basic code required. Complete source code for the sample is available in our Git Repo. Below are some of the relevant code snippets. To initialize the SDK. You need to pass in your Api key and Secret key.

WarpClient.initialize(apiKey,secretKey);

Now create and add a Listener which implements the relevant WarpClient callback interfaces and connect with the server.

Listener warpLayer = new Listener();
WarpClient.GetInstance().AddConnectionRequestListener(warpLayer);
WarpClient.GetInstance().AddNotificationListener(warpLayer);
WarpClient.GetInstance().AddRoomRequestListener(warpLayer);

Now simply call connect to establish your connection with the server.

WarpClient.GetInstance().Connect();

Once your connection is established and authenticated, you will simply join a room and subscribe it to receive its notifications.

WarpClient.GetInstance().SubscribeRoom(roomid);
WarpClient.GetInstance().JoinRoom(roomid);

After you have joined the room, you can start sending your user’s coordinates to other users in the room. In this example we will use our Chat api to do that

string json = "{\"x\":\""+transform.position.x+"\",\"y\":\""+transform.position.y+"\",\"z\":\""+transform.position.z+"\"}";
WarpClient.GetInstance().SendChat(msg);

Once the remote player also joins, you will start receiving messages from it. Handle them and move the cylinder representing it

		
public void onChatReceived (ChatEvent eventObj)
{
    Log(eventObj.getSender() + " sent " + eventObj.getMessage());
    SimpleJSON.JSONNode msg =  SimpleJSON.JSON.Parse(eventObj.getMessage());
    if(eventObj.getSender() != id)
    {
        appwarp.movePlayer(msg["x"].AsFloat,msg["y"].AsFloat,msg["z"].AsFloat);
    }
}

And thats it! Simply build and run your Unity3D application on two different endpoints and you will be able to see each other’s endpoint movements in realtime (a simple white cylinder).

opponent Make Real time multiplayer games using Unity3D

You can also add leader boards, reward management and push notifications to your game by importing the App42 Unity asset in to your project. For a complete list of backend APIs available, visit the App42 page.

Instructions on downloading this sample and getting your API Key, Secret Key and RoomId can be found in our GIT repo here. To learn more about AppWarp, check out the product overview.



3893cb46 e00d 48a3 ab37 ed895529743d Make Real time multiplayer games using Unity3D








5e4701b1 0391 4883 93c4 677289558295 Make Real time multiplayer games using Unity3D




Share it now
Be a fan!

How to add a leaderboard to your Cocos2D game

Share it now

First How to add a leaderboard to your Cocos2D game

App42 provides a rich set of leaderboard APIs. In this post, I will describe how to integrate your Cocos2D game with the App42 cloud framework and use its leader board APIs. Please see my previous blog post on why a rich leader board is important for your game.

Second How to add a leaderboard to your Cocos2D gameWe will use our Ninja Fight iPad demo game to walk you through the integration. Ninja Fight is a simple multiplayer game in which opponents have to strike each other with missiles while avoiding getting hit themselves. The game starts of by asking the player to enter its name. This is the name that will be used later to submit the score for the user.

GamePlay How to add a leaderboard to your Cocos2D game

Once two users have started fighting, the game will transition to the fight scene. This is where the realtime action will happen using AppWarp apis. Using AppWarp with Cocos2D was described in an earlier blog post. Players simply need to tap in the direction of the opponent to fire missiles. You can also move the player by dragging it using your finger on the iPad.

Leaderboard How to add a leaderboard to your Cocos2D game

Ninja Fight leaderboard

Once the game is over the user’s score is submitted and an option to view the game’s leader board is given. Upon selecting this option, the game’s leader board is displayed using our API. This will simply list the users who have submitted the top scores, their rank and the score.

Now to the actual code itself for saving scores and getting the top scorers! Here is the initial set up that you need to do once before you can use all the leader board APIs.

ServiceAPI *serviceAPIObject = [[ServiceAPI alloc]init];
serviceAPIObject.apiKey = APP42_APP_KEY;
serviceAPIObject.secretKey = APP42_SECRET_KEY;
ScoreBoardService *scoreboardService = [serviceAPIObject buildScoreBoardService];

To submit the user’s score to the cloud, its one simple API call

[scoreboardService saveUserScore:@"Ninja Fight" gameUserName:userName gameScore:score];

Retrieving your game’s top 20 scorers from the cloud is also straight forward.

Game *game=[scoreboardService getTopNRankers:@"Ninja Fight" max:20];
NSMutableArray *scoreList = game.scoreList;

The API works synchronously so you should perform the API calls on a back ground thread so as to not block your main thread. This is extremely easy using the performSelectorInBackground utility iOS method.

Complete source code for the game can be downloaded from our Git Repo with the Readme file containing the instructions on how to set up and get it working.

App42 provides a complete set of leader board APIs which allow you to add advanced social leader boards based on groups, weekly, daily top scorers etc. Similarly you can use our reward management APIs to manage in-app rewards and purchases. For a complete reference, visit this page.

Please send your feedback and queries to us at support@shephertz.com


Share it now
Be a fan!

Adding Back-end to HTML5 apps with App42 Platform

Share it now

HTML5 Adding Back end to HTML5 apps with App42 Platform

HTML5

App42 platform announces its Java Script API for Backend as a Service platform. Now, one can add backend to HTML5 Apps with few lines of code without writing any server side logic using  App42 platform. One can also choose to use different technical and business services based on app requirement and develop HTML5 Apps with  lesser time.

Here are the steps to add this in to your HTML5 Apps

  • - Download the latest App42 Java Script SDK
  • - Unzip the file and copy App42-all-x.x.x.min.js to your project  source.
  • - Add the following script tag in the your html page
  • script type="text/javascript" src="App42-all-x.x.x.min.js"
  • - Initialize the library using
  • App42.initialize("API KEY","SECRET KEY");
  • - Instantiate the service that one wants to use in the App, e.g. using User service one has to do the following
  • var user = new App42User();
  • - Now one can call associated method of that service e.g. user creation can be done with the following snippet
  • user.createUser(userName, pwd, email,{
    success: function(object) {
    // Callback for Success },
    error: function(error) {
    // Callback for error }
    });
  • - Executing above method will create user for your app in App42 cloud.
  • - You can login to AppHQ console and can see the created user there.
  • - You can also use your UserSample.HTML/StorageSample.HTML shipped with distribution for more details.
  • - Similarly one can use other App42 services like File UploadGamingNoSQL Storage to make user engaging social Apps for HTML5.

Share it now
Be a fan!

Adding Backend to BlackBerry 10 webworks with App42 Platform

Share it now

BlackBerry 10 Adding Backend to BlackBerry 10 webworks with App42 Platform

BlackBerry 10

App42platform is now equipped with BlackBerry 10 webworks SDK. This means one can make cloud enabled apps with scalable App42 platform with few lines of java script code. One can choose from different business and technical services available in App42 platform to make a user engaging and feature rich app for BlackBerry 10.

Here are the steps to add it in  BlackBerry 10 webworks App

  • - Add the following script tag in the html page
  • script type="text/javascript" src="https://raw.github.com/shephertz/App42_JAVASCRIPT_SDK/master/App42-all-0.6.0.min.js"
  • - Initialize the library using the following java script code
  •  App42.initialize("API KEY","SECRET KEY");
  •  - Instantiate the service that one wants to use in the App, e.g. using User service one has to do the following
  •   var user  = new App42User();
  • - Now one can call associated method of that service e.g. user creation can be done with the following snippet
  •  user.createUser(userName, pwd, email,{
                            success: function(object) {
                // Callback for Success                 },
                            error: function(error) {
                // Callback for error               }
                        });
  • - The above snippet will create a user in App42 cloud, if operation is success one will get the callback in success method however if it fails, error method will get invoked as callback.

Download the SDK and sample code from our BlackBerry 10 webwork repository to get started.


Share it now
Be a fan!

Engage users through social leader boards

Share it now

Mobile games have become an integral part of the industry landscape over the last few years. With devices becoming more and more powerful and internet connectivity becoming ubiquitous, there is potential for a lot of innovation and these are exciting times for mobile developers. However, with increasing competition, the challenge is to make games that keep their users constantly engaged and compel them to keep coming back.

Screen Shot 2013 03 18 at 10.55.31 AM Engage users through social leader boards

Daily and All-time leader board

Adding leader boards to your game is a natural way of engaging users. Hard core gamers like to brag and are always interested in beating the best and it is not uncommon to see them posting screenshots with their highest scores on their Facebook walls. However, most of the users of a game are not going to be hard-core gamers and would not be interested in seeing the leader boards and posting scores on their Facebook wall if their ranking is say 21,053! It will also not interest them in seeing who is at the top of the tree and with how many points, if they are not even close. How can we engage such casual gamers through leader boards? The idea is to develop leader boards, which are more relevant to the user by making them social. We make them social by showing a user where they stand amongst their friends. So while it may not interest a casual gamer to see how they are doing compared to random strangers across the world – they would want to see how they are doing compared to their colleagues, classmates, siblingsetc.

Screen Shot 2013 03 18 at 10.58.45 AM Engage users through social leader boards

Friends and Global leader board

A prerequisite for mobile developers to build such relevant and engaging experiences, is the data storage on the cloud and its efficient retrieval in the desired form. Its time consuming to deploy your own DB on the cloud, cluster it, secure it and then expose it as a web-service in the form desired by your game running inside a user’s device. App42 leader board APIs make this task easy by providing SDKs to access and save your game scores on our readymade backend. App developers can determine the relevant user list according to their App’s user management such as Facebook friends, Twitter followers, Instagram followers or their own in-App buddy lists. Through simple API calls from the SDK, App42 backend will fetch the data requested from the backend. Of course, App42 leader board APIs also provide global leader boards and leader boards based on time such as daily, weekly top scorers etc. Another great thing is that you are not tied to a particular platform since App42 leader board SDKs are available for all devices like iOS, Android, J2ME, Windows Phone, Blackberry etc.This is great if you are a mobile developer as you need not hire a backend expert or learn these technologies yourself, reducing your time to market. Go ahead and try right now!

8046709a 9a4d 4fc3 910a a3e6abc0436f Engage users through social leader boards

Share it now
Be a fan!

Why Backend as a Service – BaaS cannot be ignored for developing Apps

Share it now

BaaS2 Why Backend as a Service   BaaS cannot be ignored for developing AppsIn todays day and age one does not have the luxury to build applications, which have release cycles beyond few months leave apart years like before. One needs to be super agile and focus on your core expertise, leverage whatever one can use and release the app at the earliest. Sticking to the non-invented-here syndrome, just might be a recipe for disaster.

You imagine about an App idea, be it Mobile, Web, Gaming or Social App and most likely you will find it in one of the AppStore, if not most likely someone, somewhere in some garage or a big company is working on the same idea. Time to market is essential, releasing the app late might just loose its relevance in the market or catching up with competition might become a daunting task.

Developing a non-trivial App requires expertise at various layers of the architecture and platforms.

Device : iOS, Android, Windows 7/8, HTML5, J2ME for Mobile devices

Server Side : PHP, Ruby, Python, Java, Scala, Groovy, Closure, .Net, Node.js etc

Databases : RDBMS, NoSQL, Embedded etc.

Cloud Computing : IaaS – Infrastructure as a Service, Traditional Hosting, PaaS etc.

The developer also needs to have knowledge on setting up the right configuration for Firewall ports, Security, patches, high availability, Scalability, Performance etc.

System Monitoring & Management – The health of the backend servers and managing the servers and data (e.g. Backups), geographical redundancy etc.

For a  developers the list activities to be done and skills required across platforms and layers of architecture might consume too much of their time since instead of focusing on their core features. Lot of time goes into non-core activities.

Developers eventually might think that their idea to see the light of the day might be quite far from what they had imagined.

Even if the developer is an expert, the sheer time and effort it will take to achieve this might be more than the time and budget they have.

- It might not be cost effective for them because taking up virtual machines with IaaS provider is quite expensive than one imagines and paying them even before your App is released in the market itself is something which might effect his total budget significantly.
- Development of server side logic requires different skills, different than Device technologies and might consume lot of time and effort.Even if one decides to develop in-house, which in turn might inflate the cost.
- For Service companies engaged in outsourced App development. The development is done by two separate teams, one doing development on the device/client and the other specializing on the server side. The device team is always dependent on the server team and they always end up fighting on the desired interface or their frequent changing. This dependency adds on to unnecessary pressures on time lines and team morale.
- Managing your servers and infrastructure for Non-Functional requirements is complex e.g. Scalability, Performance  High Availability, Security etc. Also requires lot of time, effort and cost. Not to forget specialized skills especially for capacity planing, sizing and setting up the Physical Architecture.

What if some of the pain points illustrated above is taken care by an external service provider. Somebody whose bread and butter is to manage backend apps. 

- Continuously keeps on adding new features and maintaing current ones with public interfaces which are versioned.
- Keeps the developer oblivious of the complexities of the deployment of the app on the cloud, server installation and its management.
- Offers out of the box features for most of the common cases.
- For the ones which requiers some custom logic gives an execution environment for custom code to be deployed and run on the backend server along with the existing servers.
- Provides native SDKs for all popular platform for device and web.
- Makes supporting more than one platform easier since the backend remains the same only the native SDKs, which have similar interface has to be changed.
- Provides a Management Console which allows access and management of all the data generated through the usage of the SDKs

Backend as a Service - BaaS comes to the rescue. It is a logical evolution of Platform as a Service – PaaS, which tries to solve the above pain points and more. BaaS is a layer which sits over PaaS. Most often it provides a REST based interface to all its services which can be accessed through native SDKs. A further more specific platform for Mobile development is Mobile Backend as a Service – MBaaS

- The developer just needs to add the respective native SDK library based on the technology in which he is developing, write few lines of code to integrate and voila
- Gets out of the box functionality from day one. No need to manage servers, spend time in writing boiler plate code
- Have flexibility to write custom code.
- No need to learn, hire or develop most of the server side functionality
- And with all of the above save time, effort and cost.

Backend as a Service is getting evolved everyday. Its also participating in the MEAP vision  helping app developers to become successful which MEAP – Mobile Enterprise Application Platform a term coined by Gartner in their Gartner Magic Quadrant.

Applying the cliched 80-20 rule. Intention is to cover 80% of the features which one requiers on the server side for App development. For remaining 20% features, some BaaS Providers have started offering provision to run custom code on the cloud. One can even mash two or more APIs and carve out a higher level facade API.

Most Common services which the BaaS Providers offer are :

- User Management
- Storage
- Push Notification
- Social
- Geo Spatial

Some of them provide many more services across domains

Already Backend as a Service is being used by many developers across platforms. The pace at which it is evolving, it is surely a technology which one cannot ignore and to reckon with.


Share it now
Be a fan!

Build cross-platform realtime games and apps using Mono

Share it now

monotouch Build cross platform realtime games and apps using Monomonodroid Build cross platform realtime games and apps using MonoXamarin has developed a powerful platform on top of Mono which allows developers to build Native iOS and Android apps using C#. This is great for .Net/C# developers who want to build iOS/Android apps but are not experienced in Objective-C or JAVA. Another advantage of using Mono is that you can share almost all of your client-side business logic if you are building an app for both Android and iOS.

appwarp Build cross platform realtime games and apps using MonoYou can now build cross-platform iOS and Android games and apps on top of the Mono platform using AppWarp cloud gaming network. Unlike many 3rd party iOS/Android libraries which require developers to write a proxy/projection layer on-top of them when including in a MonoProject – AppWarp Mono library works as is. This is because we have specially built a Mono compatible flavor of our SDK eliminating this pain point for developers.

We have developed a simple demo chat application illustrating how you can integrate AppWarp’s mono compatible library in to your project and get access to the powerful AppWarp real-time multiplayer cloud network. Both the Android and iOS versions of the applications follow the same pattern. There are two screens in the application – a Join Screen and a Chat Screen. The Join Screen takes the user name as input and joins a room in the AppWarp cloud. The Chat screen allows the user to send and view chat messages in real-time.

Android Join 246x300 Build cross platform realtime games and apps using Mono

Android Demo Chat Join Screen

iPhone Join 152x300 Build cross platform realtime games and apps using Mono

iPhone Demo Chat Join Screen

Join Controller/Activity code snippets.

 WarpClient.initialize(Constants.API_KEY, Constants.SECRET_KEY);

WarpClient.GetInstance().JoinZone(this.nameTextField.Text);

WarpClient.GetInstance().JoinRoom(Constants.CHAT_ROOM_ID);

iPhone Chat 153x300 Build cross platform realtime games and apps using Mono

iPhone Chat Screen

Android Chat 221x300 Build cross platform realtime games and apps using Mono

Android Chat Screen

Chat Controller/Activity code snippets

WarpClient.GetInstance().SendChat(this.inputTextField.Text);

public void onChatReceived (ChatEvent eventObj)

{

    String sender = eventObj.getSender();

    String message = eventObj.getMessage();

}

Complete source code for both Android and iPhone chat applications can be found on our GIT repo here. You can see how we have shared almost all of the C# code in the iOS controller and Android Activity class is the same.

Interested in learning more about AppWarp?

Take a tour or Sign up right away!.

Also take a look at our cross-platform Leader board and push notifications apis for adding comprehensive out of the box cloud support in your games and apps.

Do try these out and share your feedback with us on support@shephertz.com


Share it now
Be a fan!

How to Create Geo Spatial Enabled Apps

Share it now

Today a significant market share is acquired by Geo Spatial enabled apps on all famous app stores. There are few consideration and challenges while making Geo enabled apps. Lets first look into what it really takes to give the power of Geo Spatial to your app. There are two main components in Geo Spatial enabled applications, one is creating the data source for geo points and another in searching the data source for given input. For example, if you want to create an app for café search, you have to first create the data source of café by creating data points in it. Here data points are individual café at specified location. Second point is searching those data points in the data source from given geo input. For example searching the nearby café from current location of user. Creating data source and searching in it require GIS data base like postgrase, mongoDB etc to be installed and should be accessible from your app. You might need to create HTTP interface over it and an admin interface for populating/creating the data points. You also have to plan its scalability, high availability, data backup and other infrastructural considerations. If you dont want to do all above stated things, App42 Geo Spatial APIswill help you in only focusing the business logic of your app and rest will be taken care by our platform. Creating Data Points for your app, can be done with App42 APIs or through AppHQ UI interface. Similarly there are already cross platform APIs available to do the search on your data source.


Share it now
Be a fan!

Challenges in Cross Platform Push Notification

Share it now

Today all famous apps run on almost all platform to cater most of the audience. To develop and support all platforms to your app requires lots of platform specific things to address. There are some frameworks like PhoneGap which has reduced this work and provided a way through which one can write entire app using this framework and then convert this into target platform like iOS, Android and more.

However there are still lots of things which are beyond the offerings of these frameworks. Making cross platform Push Notification support is one of them. Before we go into detail of challenges, lets see what are the key component in Push Notification Engine.

Key components in Push Notification Engine is described below

  1. Push Server which will send the notification to target client once message is available. Each provider has its own Server like APNS for iOS, GCM server for Android, MPNS for Windows and so on. It also provides the interface to register the application for push enablement.
  2. App Back-end Server which will send the notification to Push Server (APNS/MPNS/GCM etc)
  3. Push Client which runs on device and keeps on listening to server for incoming messages. This client is background process and is common for all applications running on the device. Once message is received it will wake up the app for which message has been received.

Challenges on Supporting Cross Platform Push Client

  • In order to make cross platform push, your custom push client should work on all devices. However there are some limitation in running a background process on iOS and Windows devices.
  • Taking app to wake-up state is another challenge imposed on some devices.
  • Spawning one push client for each app is not a wise decision because you will end up using lots of battery power.
Since these limitations are imposed by device OS itself, you don’t have a way to solve it on device. However a hybrid model can be thought of where Push Server and App Back-end Server can be cross-platform supported however device side will still use its native mechanism for receiving the Push notifications.

App42 Push Notification Service uses the same technique to deliver cross platform push notification to your app with out writing any backend server. You can send a message to any target platform from any device/platform using following sample Android code snippet

1
2
3
4
5
String userName = "Nick";
String message = "Hi Nick! you have won 10 points";
ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>");
PushnotificationService pushnotificationService = api.BuildPushnotificationService();
PushNotification pushNotification = pushnotificationService.sendPushMessageToUser(userName,message);
App42 platform will fetch the underlying device platform of registered user internally and will use the respective mechanism for sending message to user.
App42 Server handles the complexity of sending message mechanism to Push Server Provider like APNS/MPNS/GCM etc. As an app developer you will only focus on your business logic, rest will be taken care by App42 platform.
8046709a 9a4d 4fc3 910a a3e6abc0436f Challenges in Cross Platform Push Notification                      8931e3f4 f630 47a3 9675 fa5b55cf7e24 Challenges in Cross Platform Push Notification

Share it now
Be a fan!

Picking the right communication protocol for your game

Share it now

In this blog post, I will discuss the trade-offs of the commonly used protocols for communication in realtime games. One of the most essential components of building a multiplayer game is the communication between players. Picking the right protocol for your game is crucial and impacts your game’s architecture and performance.

AJAX/Long polling

In this technique the client always keeps a parallel pending HTTP request open with the server. The server only responds to this request when it has something to send (push) to the client. As soon as the response arrives, the client will again open a new pending HTTP request and send to the server. The good thing is that the same REST communication layer will work across all devices and browsers allowing you to reuse a lot of the logic if building a cross platform game. Another key advantage is that the HTTP protocol takes care of all the network topology/proxy/firewall issues for you and your games should work in almost any possible setup. The other advantage is that there is a wide array of options available to implement your game server – which is simply a web server in this case.

The main drawback with this approach is when it comes to performance. Every request by the client sets up a new underlying TCP connection thereby increasing the round trip times. Another thing to keep in mind is the large message sizes owing to the protocol’s own headers increasing both bandwidth and processing at both client and server. Yet another limitation is that any binary data you want to send will require to be Base64 encoded/decoded as HTTP is string based. Finally you don’t have control over browser time outs and need to tune the timeout values carefully. This technique is only recommended if you are building a soft realtime game which has a low frequency of messages exchanged between the users such as turn based card games.

AJAX Server Push

Another AJAX based technique is the server push. This technique allows the the server to send a stream of notifications back to the client without client sending a new HTTP request. The idea is to send an initial request form the client and then the server keeps responding with multipart portions whenever it has data to send back to the client without completing the response. This solves the problem in long polling of having to establish a new connection after every response but the channel is one way i.e. from server to client. When the client has new information to send to the server, it will still need to send a new HTTP request. This makes it ideal for applications such as facebook and twitter feeds where the server keeps updating the client. A deeper discussion on this can be found here. An upcoming feature of HTML5 known as server side events is aimed to provide the same behavior without the need of doing all the multipart response work on the work from the server.

TCP

This is the most commonly used protocol in realtime games. The bidirectional connection is kept alive throughout the life of game play – making it easy to push async updates from the server to the client. It frees you the strict request/response HTTP paradigm which hinders the long polling approach. The other advantage is the ability to send binary data and flexibility to develop your own messaging protocol optimized for your game’s scenario. This is great plus as it reduces the message size, bandwidth and doesn’t require Base64 encoding. Since the persistent bidirectional TCP connection is initiated from the client – it also works across most NAT topologies and doesn’t require you to do something like UDP punching to communicate when behind a NAT. A good understanding of socket programming is a must before you begin as investigating bugs and issues can become quite time taking. The other thing to consider is that while most devices allow TCP socket programming – there are differences in the way they are exposed to the developer so you might find your iOS layer looking quite different to your WP 8 layer for example. Which also means that you may have different bugs in different platforms of your game!

UDP

One can think of UDP as a simplified version of TCP. Its simple in that it does less (no sequencing, no sliding window) and guarantees less (no reliability, no in order delivery). Since the reliability and sequencing overhead is not involved, it makes UDP even faster than TCP on an average. Similar to TCP, UDP allows you to send binary data and means you can build your own optimized messaging protocol. The obvious drawback are of course lack of reliability and potentially out of order delivery of messages. The other problem is when it comes to NAT traversal as there is no persistent connection kept alive as in the case of TCP. You will have to employ techniques such as UDP punching, STUN etc. to get your game to work when behind a NAT. Also many cellular network providers will simply block UDP traffic making your game unplayable when on 3G.

If you do decide to use UDP – its recommended that you use TCP in conjunction with UDP. Use TCP for operations such as join/leave room, chat, sending and responding to invitations etc. Essentially use it for operations that are not hard realtime but can impact other players and the game play directly. You can then use UDP for exchanging in game operations such as updating car coordinates etc. in a car racing game for example.

WebSocket

The most popular feature of HTML5 for game developers is WebSocket. This is essentially a wrapper around a TCP connection between the end users browser window (tab) and the server. WebSockets allow you to send binary data from the browser thus opening up the possibility of building your own custom optimized protocol optimized as in the case of TCP and UDP. Most of the advantages and disadvantages of TCP directly apply for WebSockets as well. Note that while sending and receiving data from a web socket is straight forward – you need to do some additional work on the server. This is because web sockets do their own binary encoding on top of TCP. So you need to special case this when handling TCP connections on your server if you are supporting both native TCP connections and WebSocket TCP connections. Another thing to be vary of when selecting websockets is that they are not yet supported on all browsers. A demo of a multiplayer game using websockets can be found here.

That covers the most common technologies and protocols that game developers use for communication in multiplayer games. Hopefully you will find this post useful and good luck in building your multiplayer game!

What we are doing?
appwarp logo Picking the right communication protocol for your game

We have developed AppWarp in a way that we abstract all the nitty gritty details of protocols and their implementation from game developers. AppWarp supports TCP/UDP in the native SDKs and WebSockets in the Javascript SDK. This allows you to build cross-platform games easily and in a short time as you don’t need to spend time debugging and testing your client and server communication layer code.



3893cb46 e00d 48a3 ab37 ed895529743d Picking the right communication protocol for your game







58373e51 32a5 4e21 ac5a 38d4c3db8a3a Picking the right communication protocol for your game




Share it now
Be a fan!