Socket vs Database in Game Creation - android

I am creating a multiplayer game for android which will be like: you choose a character, you get an oponnent and during this player versus player "fight", they only click in buttons which are the "attacks".
Though at first it seemed like a simple task I am not quite sure how to do the communication between the users of which attack was selected by the opponent, but I've come up with two possibilities: Sockets and Databases.
Sockets seemed like the best option, however, what I've found is that they only work on the same network, what definetly doesn't serve my purpose.
About Database I am not sure if it is a good idea, as making so many requests to check whether the other player has already chosen would make the game laggy I think. I have even created an Firebase account, as their Realtime Database seemed much more reasonable to use, but I couldn't find any way in which I could integrate Firebase with LibGDX (which I am using for this app).
To sum up, the answer is: what is the best way to exchange data quickly? How could I implement it using LibGDX?
I am using Android Studio if it helps anything and am on 0$ budget.

Because of the $0 budget then getting a VPS (virtual private server) is out of the question. So you need another alternative. Run your server from home, from your own PC.
Your next step would be to get a free dns service which will redirect a web address to your home routers IP address and from there you can setup your router to redirect ports directly to your PC. These can be web ports, or ports for TCP use.
You will then have a choice of what to use:
1 - Web sockets which can be used by various languages that will run on the server.
2 - TCP/IP server which is less overhead than web sockets and is direct communication via TCP to your server.
Both of the above will have their strengths, but it is up to you where you start. The server software itself can be written in many languages, including Java which will be more compatible with your current Android project.
There's no way I can explain in depth any further without other questions being raised. So from here, it's a lot of research in the various technologies.

Related

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.

system for bidirectional realtime communication between tablets and server

We are going to build a multiplayer game.
The idea is that every player has a tablet and is connected to a server.
The server should control the game logic, while the clients (the tablets) will only serve as a frontend to the game.
We need to make a decision about the frameworks/programming language we are going to use.
A crossplatform frontend would be cool, but is not mandatory. It has to run on Android devices at least.
The communication between the server and the client must be bidirectional and realtime.
We don't care about a small amount of delay.
Currently we consider an HTML5 client in combination with a javascript server (running upon nodejs) to be the best option.
The communication would be managed by the javascript library socket.io.
The HTML5 frontend can be run either in-browser or as an app (built with PhoneGap).
However we did not decide yet since we want to be sure to make the right choice.
There might be frameworks that can do a better job.
Does anyone know a better solution?
Play 2 is great for this well, but node/socket are great choices too. I would use backbone.js for the front end as it gives you a lot of flexibility and it's easy to keep the views in sync. (there is an example of such an app on my github if you're interested)

Ideal approach to create multi-player game server for Android (a game with very basic graphics)

I'm working on an Android game based on Playing Cards (Bridge, to be precise), which can be played by four players at time. And there'll be a server available via Web, to which devices will connect, and server will keep track of game progress.
My game is very basic when it comes to graphics that I can attain the UI without using any gaming engine.
While I'm supposed to build the game (the client) for Android, I wanted to develop server which can be RE-USED in future ports of the game, even if it is ported to other mobile platforms or even desktop.
So I thought of first possible candidate for server architecture was having RESTful Web Service so that I can leverage the server with any client as long as the client's programming end supports HTTP methods.
But later I realized that since there'll be persistent connection between devices and the server throughout the game session, would it be okay to have such a server, where connection will terminate after the request is responded (I'm not sure if it is true)?
Or shall I use DatagramSocket and DatagramPacket way of Java to build the server? (will that ensure re-usability of server?)
Any other suggestions or recommendations?
Note: I'm not new to Java or Network Programming in Java, but I'm new to both Android Development and creating RESTful services.
While writing for Android, don't plan for a persistent connection. Connections break very often (and often for good reasons, like switching from GSM to wifi). HTTP is a great, popular and proven choice (you get some lower levels of the stack out of your way and can focus on processing the payload).
BTW: saying "RESTful web service" int this context is meaningless - what you need is a HTTP server that serves data and accepts commands, not a mental framework for structuring your game logic as a set of stateful resources.
I think your HTTP-based plan is appropriate for this situation, I don't think the question of persistence of connection is relevant for a slow turned based game such as bridge.
Edit: as suggested by tdreger almost all Android docs recommend that you plan for routine connection failure and reestablishment through a different channel, as such the html connection seems the most resilient solution.
I think your idea of making it client-side independent is correct and important - in this light the HTTP idea is clearly much better in that it will be much easier to code client-side applications in other languages (which you will probably want - Javascript for a web-client and objective-C for an iOS app).
I also think the Android development will be easier as Android and appache have strong support for these HTTP-like connections.

android multiplayer gam

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.

2 way communication between a .Net server and a mobile OS

I am trying to build a game that for both android and iPhones that communicate with a .Net server for sending and receiving data about the game state. One of the requirements is that I am having an issue with is that I need a way to do 2 way communication in near real time and I can't seem to find a way that works. Also if it helps I am primarily visioning this game being played over a wifi connection to both the server and the clients for at least the first release.
I have tried looking at the push messaging services but they do not seem to be fast enough. I have also looked at using a netTcp binding in wcf but that seems to require a .net client.
Does anyone know a good way to solve this problem that I may have missed?

Categories

Resources