i'm currently programming an iPhone game and I would like to create an online multiplayer mode. In the future, this app will be port to Android devices, so I was wondering how to create the game-server ?
First at all, which language should I choose ? How to make a server able to communicate both with programs written in objective-c and Java ?
Then, how to effectively do it ? Is it good if I open a socket by client (there'll be 2) ? What kind of information should I send to the server ? to the clients ?
Thanks for your time.
EDIT How massively multiplayer'ed will you game be?
Hi Cyril,
as you noticed, there are two main things two consider:
information sent to the server
information sent to the client
There's only one type of information to sent to the server: the user inputs. If you don't do that, you'll encounter headaches over headaches when rogue client will try to send fake data to your server (like saying "My tank now has 100 000 000 armor").
Then what you sent to the client is up to you but it's totally possible to only sent to the client the other player(s)'s input. This is the way to have the absolute minimum and tinies bandwith usage possible. That is how games like Blizzard's Warcraft 3 are doing it. As a bonus, this makes for tiny replay files (because all you need to do to be able to replay a game is the time (and the input) at which each player's input happened).
The one downsides with sending only the other player's input to the client is that it means all the game's logic is present on every client. For some games, this may be an issue because people may cheat by reverse engineering your game and finding flaws. This issue can be mitigated with careful, controlled, randomization (where in addition to the input+time you send input+time+randomness where randomness cannot be guessed by the client in advance.
Another way to do it is to do some logic computation on the server side. Then, obviously, you need to send the result of the server computation to the client. Done correctly, this has the benefit of both preventing cheats and maky piracy impossible (for example nobody managed to play World of Warcraft in the real economy --that is, on the real Blizzard servers-- using a fake licence key).
Regarding the phone-turn-based game server: just look at one top-selling turn-based game are doing it. Take Uniwar for example: works on iPhone and Android. Game server is written in Java "of course".
The one thing to realize is that a game like the one you plan to write is entirely deterministic: if you can't easily code a replayer or if you can't easily reproduce any kind of scenario leading to a logic bug, you're doing it wrong.
Note that being determistic doesn't mean you can't add what looks like randomness to your players: it's simply that the randomness shall also be deterministic (for example by simply using a different seed for each game + the time at which player inputs are made as a fake random source).
This is a bit lateral solution to the question asked. One of your options is to use Gamooga (http://www.gamooga.com/) so you donot need to worry about the server side, the sockets, the transport logic etc. You can just concentrate on your game logic and just develop that than the required systems stuff.
Gamooga provides you with a realtime communication platform to be used in your games. You can upload your server side message processing scripts to Gamooga's cluster and use its iOS API with in your app to send and receive messages from/to the server side. The server side is auto scaled and managed for you by Gamooga. You can download the SDK and start off with the demos with in the SDK.
Disclosure: I am founder of Gamooga, replying only since its relevant to the question.
Related
How can I show real time database changes in a flask website?
Like on_update and on_insert, the data will be pushed to the website for the user to see.
I want to get alert from an IOT device and insert it to the database and the users who are subbed to that device should get the real-time alerts.
So I thought
>IOT detects
>HTTP POST to database
>Flask App detects the database change
>push to clients on web app and android
I made a web app that queries the DB with flask-sqlalchemy but thats it, these are supposed to be real-time alerts! I'm so frustrated it's been a week. I am going nowhere and I feel so lost now.
>polling
>web sockets
>SSE
>flask sse
>use AJAX
>use JQUERY
HHHOOOOOWWWWW?????? Most of the examples are for chat apps, and I see NO method where you listen to database changes and send it to clients ;(
A very easy way to implement this is using an event SaaS like pusher.com. This should get you set up in no time. They have examples for many different languages and it should fit your need perfectly.
You mention that you see so many chat-apps as examples. This is pretty normal as they are almost the "hello-world" of event-based systems. And that's exactly what you are looking for. An event happens and you want to trigger something on that event.
For chats, the event is: "The user entered a message" and the triggered action is: "Display it to every connected/subscribed user".
Next to a hosted service like pusher.com, you can roll your own. All the required technology are free and open standards. You could use websockets or WebRTC for this. Websockets is easier but it's trickier if you have many open channels. On the other hand, WebRTC scales but it's a bit more complicated to set up. But you won't need video or audio which makes it easier.
You mention "polling" and I am not sure whether you mean "normal" polling or long-polling as in Comet. That is of course an option. It is the easiest solution, but not the cleanest.
SSE seems like a valid option as well. Although I have no personal experience with it yet. But it seems like it's designed for this use-case.
AJAX and jQuery are less related. AJAX is just an umbrella term for programming using XmlHTTPRequest and is used in all solutions mentioned above. jQuery is just a JS framework and is completely unrelated to the task.
long story short: All your mentioned options allow you to do this. I would suggest looking at pusher.com to get started. And their examples have exactly what you need. Their free plan is already really generous for personal projects. If your application outgrows the free plan you can either pay, or roll your own solution.
So basically I have made a few small apps in the past, but this is my first 'proper' app.
One of the main features of the app, and the bit that I am struggling with is that I need to be able to populate a ListView with all of the other users logged into the app, however I only want to display users that are within a set distance, for example 10 meters.
I tried using Bluetooth to achieve this, however that didn't work. I would now like to use location services to do this.
My idea is to have to app send the location of the device to an external server every few minutes and then all other devices can run a function that compare their location to others found on this server.
Does anybody know how I could go about achieving this, or know of any tutorials that cover a simpler topic. Thank you
Disclaimer: I'm not an android developer, but this seems like a design issue not a implementation issue so hopefully my comments below might be of some use...
I don't think there's an API that you can just set to "true" to get this functionality, so I think you're going to have to custom craft all the moving parts (and there are a couple). I would think the general process would be something like:
On the client:
User on client logs in to server with some sort of identity (i.e. "user#gmail.com")
Every X minutes the client app gets the current location (i.e. "100N 90E") and sends it up to a server
Every X minutes the client polls the server to see who is within 10 miles (i.e."joe#gmail.com", "mary#gmail.com")
On the server:
Needs some sort of authentication endpoints for getting a user's identity
Needs an endpoint for users to register their location ("user#gmail.com is at 100N 90E")
Needs a service to find out how far each user is from each other
Needs an endpoint to return the users within X miles (list generated from #3)
Each one of these steps shouldn't be difficult on their own and you can actually get pretty nuts with the distribution algorithm on server step #3 if you wanted to.
Some questions you can ask yourself are:
"How do I set up a server to listen for HTTP requests?" - Take a look into Node.JS for a simple solution
"How do I get a user's location in android?" - Easy google search finds plenty of documentation
"How do I write a service to continuously perform actions?" - Node.JS would again help with this
"Where will I store user's locations and their distances from each other?" - You can look into a NoSQL option like CouchBase or MongoDb. Or you could use MySQL for a more structured database.
Hope this helps...
I'm making a chess game,playable from both, an android device as well as a web browser.I will take input from user in a UI, & processing of that input-updating gamestate should happen at backend/application server.The response from server goes back to UI which displays the new gamestate.
Now my question is, what are possible options for application server I can explore to actually do this ?I'm not asking which is best or likewise....I just want to know what application servers are there which I can use to make my game.
I've made a similar application in netbeans using glassfish,but this time, I want an android device to be able to communicate with server too, so I'm confused how to approach this.
I've already tried google play services,but additional data about player,his statistics,etc needs to be stored client side,which I dont want.
Please suggest some alternatives.
I'm making a client/server game app for android. Currently I managed to get the app working using two locally known IPs. My issue now is how do I go about making my app pair client/servers randomly.
I was thinking that initially every person starts as a client and they connect to a master server. The master server then pairs them together and specifies who will be the server and who will be the client between the two. If this is the best way to do it, how do I go about making the master server program? What kind of server do I set it up on? I'm in the dark about how to go with this.
actually i did not answer right away thinking i would waste the night in needless fear but let us - if you don't mind - bump the issue up the hill - given just now i am going clickety-click looking for places to put up my first app - i found 2-3
let us examine the chance to do conceptual work on what is called stochastic List
given a large dataset = available apps
and another large dataset = people looking for apps
how would we code a fair presentation algorithm as some numbers like 100,000 are not out of scope but we get the same 10-20 apps on many keyclicks & not get much done - thus:
class Customer{}
class Application{}
Map <BigInteger,Customer>
Map <BigInteger,Application>
then we look into SecureRandom to pull from the application base ....
lot of work to be done but major point is to use SecureRandom rather than Math.random for several reasons ..
I have finished and released my game and it contains a local highscore list for each phone. I would like to make it so that the scores are global..ie. send score to a server and server sends the highest scores to all the phones when they connect
Unfortunately I have no idea where to begin. So if somebody could point out a link or give me an explanation on how to proceed I'd be very appreciative, thanks!
You have the general idea. You have to:
Send the score to a server
Retrieve the high score table from the server
This means that you probably want to have some sort of web-based API for these two. The easiest way is to simply let someone else do it. There are free services out there that already provide global high scores. There are probably more, but for Android, OpenFeint and ScoreLoop are two big ones that I know of. You can look through their docs and see if you want to use them.
Alternatively, you can roll your own. This is a bit more work (though honestly not all that hard). If you go this route I'd recommend you build a web service that you can post scores to. The web service would save the score to a database and then when the client calls the web service to retrieve scores, the web service queries the score database and returns them.
That's a general outline, because frankly how to build that web service is a whole other question, and you'd have to decide on a language/platform etc. for that too.
Check out Swarm's Leaderboard system, which is similar to the others mentioned here (ScoreLoop/OpenFeint), just another alternative to consider :)
Have a look at Scoreloop 1.0 in NDK 2.0 release for BB.
https://bdsc.webapps.blackberry.com/native/beta/?CPID=TWDToolDL&Date=112311