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?
Related
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.
So I am developing a little game in which the users will try to answer the same question in real time. I thought the best way for the users communication is p2p. After 3 days searching, I found that there 3 possible solutions.
1. XMPP. Recommended by a lot people. Unfortunately not many people in China use GTalk.
2. Jxta. Seems dead and complex.
3. SIP. It requires the user to have a SIP account.
p2p seems to be really hard on cell phones.
My question:
Is p2p really the best solution to my problem?
If it is, what is the best way to achieve p2p connection on cell phones?
Many thanks!
If the only issue with XMPP is that your users don't use Google Talk you should set up a server and rely on in-band registration.
Look at these Q&A to learn what it is and how you can get it in android
An XMPP server is easy to setup, use OpenFire. I've done this before, you have to install a java virtual machine on a server and then install OpenFIre.
To create a client application, you can based your work on the ASMACK library which is very complete.
For me, it worked but my server cann't handle OpenFire. I just have a dedicated server with 512 RAM and 20 Go SSD to a VPN connection.
So I am a relatively new iOS developer but thanks to Stackoverflow, i managed to get peer to peer data communication for my app working without the need of a server using gamekit/GKSessions.
Basically, one iOS device acts as a server and others just connect to it to receive app specific data.
Now, the app is currently being ported on Android and I was wondering if there is a way that I can make an Android device connect to the iOS app and behave the same way as ios app does.
Android developers suggested alljoyn to be an optimum solution for android but that doesn't seem to be available yet for iOS.
Please suggest if you have any ideas on this front.
If there is a solution that involves rework on iOS side as well then I am open to it!
In case, you or others tackling the same question in Jan 2013 needs an answer,
AllJoyn is now ready for iOS too, amongst other platforms.
https://www.alljoyn.org/docs-and-downloads
Venkat i suggest you to read and get some detailed information regarding P2P. This is a Good source, because you might get stuck if both devices are behind multiple Nat. but if your willing to go forward there is always a way. My suggestion would be an Relay, but you need to have a server, but the relay behaves like P2P. Look at the source above to get ideas.
I didn't have time to wait for alljoyn to be launched for iOS and sensing no other feasible solution that would fit on my timeline, I implemented a relay server in between to achieve this.
For others though, iOS binding is now available for alljoyn (www.alljoyn.org).
I haven't tried it yet but the android version of my app works with alljoyn and it works perfectly so I assume it will do the same for iOS as well.
One limitation to be considered using alljoyn is that it cannot communicate between devices that are behind different subnets.
I think there is a limit of max peer to multiple peer connectivity (max 8 peers) derived by IOS and Android, there is no connectivity tested using alljoyn between IOS and Android devices
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.
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.