android multiplayer gam - android

I am trying to develop multiplayer turn based android game which will be coordinated using a remote server. I want to use couchbase nosql server with java sdk. I do not understand how data will be moved from mobile to database and back. Could you please help me ? Do I need to use jetty or tomcat ? Is there any other way ? Mostly I have worked on client side only so I am not able to figure this out.

You need to get started with socket programmming in java , the most primary thing you should know when developing a network app.

You should consider a REST-ful interface between the client and server instead of sockets, especially if it's a slow paced game (like Words with Friends or Draw Something)
The basic idea is that the mobile devices post data on various pages you have set up using a server:
http://mygame.com/mobile/api/submitMove?id=123&player=1&move=KnightA4
the server will then read the arguments, figure out if it's valid using a database, and respond back accordingly.

If you want to learn about servers and develop the server from scratch, I can relate to that BUT as a client developer it may take you a lot of time to configure, develop, test, run, host, maintain, scale the server side (and ofcourse it may cost you a great deal of money). If you are looking to release your game as quickly as possible I would propose another solution. I am from Skiller and we have SDK that should shorten the time it will take you to get your game on the market. You can use built in turn based simple API to create or join existing game, challenge players, send messages and much more...
Check our wiki pages or our Skiller website for more info.
Will be glad to get your input.

Related

Implementing online connectivity and multiplayer/PVP for a newbie

Background
I'm a noob programmer looking to create a simple turn based mobile game as a side project. I've pretty much got the game logic down and am left with implementing the online multiplayer/PVP portion.
More specifically, i'm looking to implementing a system when the player clicks play and will be matched with an opponent in a 1 v 1 format, without any lobbies etc etc.
I'm currently trying to develop my game in android studio(i'm new) but am also open to unity if it makes the development easier.(I have no experience in Unity).
What i want to know
From what i understand,i need to create and host my own server for the multiplayer to run(i.e matching of player to opponent). Do i also need the server to run the game itself or am i able to connect the player to the opponent and simply record the result of the game to my server/database?
Also, how would i go about creating and running/hosting the server? I heard nodeJS is a good choice for writing the server.
Can anyone point me to a good resource/tutorial for creating and running my own server, and if possible free(or cheap) hosting for my server?
Also, is unity a better choice than android studio for my game?
End Goal
I just wanna publish my game onto the app store,IOS store,etc etc.
If you don't have any experience with creating multiplayer games, I'd recommend looking into one of the several ready-made solutions available on the market (Unity Multiplayer is one such service). You could essentially make your entire online game without ever needing to code a server.
Coding game servers is more work than you think. You'd first need to make a working game server, then you'd need to consider hosting, data storage, scaling, ping, etc. The downside is that you'll get less customizability and less security (you'll need to handle much of the game client-side, which means you're susceptible to hacking by modification of the client, known in the android world as "mods"). However, if you're just starting out, a game server of your own will probably do more harm than good.
You should always choose a multiplatform engine for mobile games. You do not want to code your entire game twice. So yes, Unity is a good choice, and it's the de-facto standard for mobile these days. If you're going to be making games, learning Unity is a worthwhile investment.
Last, and this one comes from my personal experience only with no real statistical data to support it, people who implement game servers with node often end up discovering that their server just can't handle the load, which leads to a need for stacking a whole lot of technologies up on one another to scale the server(s) out or squeeze more performance in some way. It'll often prove to be bad choice in the long run. Or then again, maybe the people I know just aren't good with node.

How to make the server backend of a mobile app?

I am an Android developer and I want to make an app which shows users on a map and performs tasks based on their location.
The whole model of the app has to run in the server. I need an API which:
Receives user location
Performs calculations based on the location of the users
Sends response to specific users with the results
The problem is that I have 0 experience in doing server side programming.
Can you please suggest me a way of making the server?
I checked the Google Colud Platform and this video. The video addresses the connection between the app and the server, but what I really need is coding the model and deploying it on the cloud.
What is the way for me to build the API for such an app, as a developer with no server side programming experience?
Can you suggest me a tutorial which goes trough the process of building a cloud backend for a mobile app?
This is a very complex question. I don't recommend using a "ready-made" solution like FireBase because it's even harder to transform it into a "proper" API later on when you need it. If you know Android then you know Java, you'll have no problem learning working with a framework like Spring Framework which I recommend. Java on the backend needs a Java Servlet container, like Tomcat. First you should set up a development environment on your machine for this. I recommend searching for Spring Framework tutorials for this i.e. Spring Framework REST tutorials.
Secondly you'll need a database like MySql or MongoDB to store data. Spring comes with ready made connections to most of the most common databases, so its pretty easy to work with them.
When you're ready to deploy your service I recommend using a PAAS like Heroku.com where you can run your service for free first. In this way you get to control everything yourself and you also learn a useful skill.
Since you are coming from the JAVA background you just need some basic building blocks and you shall be good to go.
Use PASS: They will take any devops from your side which will be a big relief considering you are not familiar with anything on server side. I recommend using Heroku or App Engine. Here's guide to App Engine with JAVA on top. https://cloud.google.com/appengine/docs/java/
Database: Not sure how you are storing and managing your user data as of now, but if you need database, there are various of those available now. The reason Firebase is top suggestion, cause it leverages realtime and gives you control on your side without spending a lot of time on your side.
APIs: You will be taking user's geo-location and sending it to server. On server you will need to process that into a real world location and any other logic. You will need to use Google's GeoLocation and reverse geocoding APIs for that. Find apis here : https://console.cloud.google.com/apis/
Also if it's any help, App Engine and Heroku both offer free limits and should be pretty sufficient for your use case.
Since you have limited experience on server side development I'd suggest using a backend-as-a-service platform. This approach has the benefits of allowing you to focus your time coding the client where your competitive differentiators are, and lets you leverage years of experience in server-side development without having to ramp up on the technology. It also means you can iterate quickly and test features ideas with less risk.
There are several options out there, but in your case, you'll need something that provides enough flexibility to implement custom logic and a custom data model. Some platforms allow you to create a full backend application with REST api endpoints, and automatically take care of deployment, security and management. Some examples of backend service providers can be found here https://en.wikipedia.org/wiki/Mobile_backend_as_a_service.
Some of the platforms actually allow you to build a full custom app without actually writing any code, and some of them provide ready-made components (like chat, leaderboards etc) but are less flexible.
Here's a list of Backend-as-a-service providers:
https://quickblox.com/
https://www.appcelerator.com/
http://www.configure.it/
https://cloudboost.io/
http://api.shephertz.com/
https://backendless.com/
http://pipegears.com (No coding required)
You didn't provide specific details about the tasks you want to implement on the backend, but it's likely that you could satisfy your requirements with a straightforward REST api that accepts your location data, runs business logic, reads or writes from your data model and returns whatever data your client needs. (Sorry I can't get more specific without details on your requirements). If you're dealing in sensitive information like location data, I'd strongly recommend securing the api with TLS/SSL (i.e. https), or make sure the platform you use provides this.

Android Application Backend from scratch

I am developing an android application which needs a backend to process login and store data remotely on a server. I have previously worked with a BaaS service "Parse" for android. but since this is my final year project for my university I need to develop a backend from scratch, I have never worked with web services. I need some guidance on how to approach this and which framework will be the best to work with.
Thanks in advance.
If I understand you correctly you want to build a server application that allows you query data from your android app?
I'm not an expert on this since i just started coding myself, but I did do some research and it seems to be a very viable option to implement a RESTful API on the server side. The wiki article is pretty specific about how it works.
If you can use PHP the slim framework allows you to get a scrappy prototype RESTful API up in less then an hour if you familiar with the server configuration. It seems to be sophisticated enough to drive small and medium sized projects (maybe even big projects; I can't tell to be honest.)
On the start page you can see an example that allows you to query for a "hello, world" string from the API with less then 50 lines of code.
http://www.slimframework.com/
Where the example returns a "hello world" string you would perform database queries using PHP and return your results as json objects to your client.
The benefits of this are that you can use this Backend for different clients: Android, iOS or even your own browser-based web application.
This also makes it easy replace / port the backend once requirements change since it's very easy to implement the same API using other technologies and languages that fit the requirements better.

Communicating between mobile devices over a local network

I'm a complete newbie with regards to developing for Android, and for starters I'm trying to develop a simple card game that can be played multiplayer over a local network. I'm having trouble finding a starting point for how I would go about this, I can find plenty of things for communicating across the internet but not having much luck seeing how you communicate directly between two devices over a LAN.
It's a major part of my plan for this app that it be multi-platform and that iOS devices and Android devices can play against each other, so I'm looking for a method that supports this. I know it's possible as I can see there are other apps that have this functionality.
I don't need a detailed implementation (although the more help the better!) but if anyone could just point me in the right direction for how to go about something like this, I'd be really grateful.
I think u need a connection peer to peer, android implements Wifi Direct
Look android dev site. http://developer.android.com/guide/topics/connectivity/wifip2p.html
For a card game I recommend using client-server.
Electrotank is a good server that provides a framework that helps you create a game of this type, with rooms, chat, friends list and connect to Android and iOS. U can write server plugins in Java.
http://www.electrotank.com/es5.html.
Another good server solution is SmartFox.
Or you can create a turn-based game, creating a database to save data and a counter on each client, where you will limit the time for each move, from this time you send data to the server and your opponent query this data the server.
I was working on the exact same thing. You'll want to use sockets to open up connections between multiple instances the same app.
I created an example app that demonstrates how to do this which I link to and explain in great detail here: http://brendaninnis.ca/connect-nearby-devices-part-2.html
I have an example for both Android and iOS that communicate with each other.

Better solution to my real-time online Android game

I developed a trivia game a while back for Android that allows you to compete head-to-head against anybody in the world that is available, in real-time. This is in real time because you can see what the other player is selecting. Since I was familiar with PHP and MySQL, that is what I chose to use on the server side to handle everything. I know this can't be very efficient since the game is constantly sending/receiving information to/from the database throughout the whole round as fast as it can. This has been working pretty good for over a year now, but I really haven't had a ton of players on at the same time, and I know there has to be a better, faster, and more reliable way. I'm planning on making this a 4 player game and I know the database will be getting hammered and will be harder to keep all of the players in sync.
What would be an appropriate way to do this? Is this something for sockets? Is the method I'm using now ok for real-time play and I just need to concentrate on improving what I have?
Raw sockets need you to handle a lot of issues. Mobile networks can disconnect easily. What you are looking to develop is similar to a chat application where you send data between users. Php by default is not best suited for this.
You could build this around an XMPP server. The key is being able to send asynchronous responses to the clients. If you need more control, you could build this on frameworks like socket.io or SignalR.

Categories

Resources