Set up server for simple iPhone game - iphone

I am looking for information on how to create and run a simple server game that will take turn information from one user, do some number crunching and pass the resultant information on to the other players in the game.
What I am looking for is a push in the right direction. While I have been coding for the iPhone for almost two years now, my server experience is limited to making a URL request to a PHP script that pulls information from a database and return it to the iPhone requesting the information. I have no idea how to take information from an iPhone and send it to other specific iPhone or players.
Any help you can give is greatly appreciated. Tutorials would be nice but even just a hint of how to go about doing this would be fantastic.
Thanks.

If you have more experience on the Objective-C side, I recommend you use iOS 4.1's Game Center connectivity to connect your users. Once you've established a GKSession between your users, sending data to all the connected peers is a snap. You could do your number crunching on one device that acts as a server and send the result to the clients for processing. This is how I do the peer-to-peer gaming in my iOS game, Cee-lo. Check out the Game Kit Programming Guide.

You should look at creating a RESTful web service on PHP that accepts your players data. This service can post the data to your database. When other players request the data from your PHP page, it can just request the latest from the database, which should have the latest friends information.
This a fairly common pattern, you can lookup using JSON to send and receive between the iPhone and a PHP site.
Creating a rest api with PHP

Related

Server framework to use for realtime iPhone app

I am currently writing an iPhone application that sends and receives JSON data from a remote server to essentially display realtime information. Me and my partner started the project using Google App Engine (Python) for the server-side implementation mostly because it was easy to pick up and seemed suitable for our needs at the time. However, we're only just now starting to see the downsides of the framework for realtime iPhone apps - APNS is not at all supported, and neither is the GAE Channels API. So our only option for displaying the realtime server data on our app is to continuously poll the server, which certainly seems like horrible design.
We'll have to port our server-side code to a new framework. My question is, which one do we use? From numerous searches, I still have yet to find a satisfactory answer.
I should mention that I don't necessarily want the server to send push notifications. I just want to be able to push data to clients in real-time, and then manipulate that data on the iPhone client-side code. We're fine with setting up the framework on a local server if we have to.
Since you don't want to be pull data in background (lett alone if it is even possible)will have to use APNS.
But why switch away from google app angine, you could use an APNS provider like Urban Airship wich provide there on API to connect with.
You'r not even the fist to run into this problem: Apple Push Notifications on Google Appengine
Probably the easiest realtime framework you can use for sending data to iOS clients in real-time is PubNub (http://www.pubnub.com). It's reasonably priced, and it scales to anything you can throw at it. In my experience, it has no problem delivering a message to an end client in under .25 milliseconds (regardless of the number of clients it's being sent to).
Their latest version also supports APNS functionality for when you app isn't in the foreground.
https://github.com/pubnub/objective-c/blob/master/iOS/README_FOR_APNS.md
If you want to create your own APNS server (since you are running on App Engine anyway), there are examples of how to do that using App Engine's new Socket API. I've written a demo python AppEngine application that people might find helpful in this regard.
https://github.com/GarettRogers/appengine-apns-gcm

iphone XCode-Wifi connection

I am a beginner in iPhone development. I have a single static IP server in my company. I have one web service on that server which gets data from an intranet MSSQL server. I would like to get that data over WiFi to an iPad app, but only over our intranet.
Have any useful links or a sample project? I am using XCode 3.2.6.
It sounds like this is a simple web service consumption scenario, so I would start with consuming it using JSON as the transfer data format and using NSUrlRequest.
Here is an article that walks you through everything you need to know in almost painful detail. It should get you where you wish to go.

How can I implement multiplayer in my iphone game?

I want to create a playstation home style multiplayer game for iphone. How can I implement multiplayer in my project? Also, how can I give players a chance to chat? How can I let them create their own avatars to interact? I am a one man developer, with no access to servers. Maybe I can use iPhone game centre???
If you're looking for some kind of platform to build on, there is a product called SmartFoxServer:
http://www.smartfoxserver.com/
I have not used it, but it claims to provide a client API for native Obj-C or Unity3D. It allows for chat features.
If you want to roll your own, I recommend getting started with NodeJS:
http://nodejs.org/
GameCenter does not provide any kind of backend for multiplayer networking, at least not in the way you are implying. If you intend to build a networked multiplayer game over the internet, you most likely need some kind of backend.
Slicehost is a good way of getting a server like NodeJS running quickly and cheaply:
http://www.slicehost.com/
Don't forget that GameKit in iOS allows multiple devices to find each other locally (via Bluetooth or local Wifi) and create sessions. This might be a good starting point for your game. Here's some info on GameKit:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/Introduction/Introduction.html
I think this would usually be done with webservice interaction against a server. You may be able to develop a webservice and pay a small fee to have it hosted by a web provider, or to use your own machine as (an unreliable) server while proving the concept.
Or you could just use Nextpeer - http://www.nextpeer.com
It makes adding online tournaments to your game real simple.
You can look at Gamooga (http://www.gamooga.com/).
Its a realtime communication platform for multiplayer games so you dont need to worry about building and deploying your own multiplayer servers. You can upload your own server side scripts onto Gamooga's cluster which receive and process your clients' messages. You can use Gamooga's iOS API with in your app to send messages from the client side to your server side scripts. You can download the SDK and look at the demos to start off.
There is a free plan of Gamooga platform too that you can make use of to start with.
Disclosure: I am founder of Gamooga, replying only since its relevant to the question.

Best practice: Send continuous Data (like GPS Position) from iOS to another client

I'm looking for a best-practice for the following scenario:
A Mobile Device (iOS) sends its (Sensor-)Data to another device (iPad, Laptop, PC, whatever) over the Internet in realtime.
Sure, I need a web service but as far as my understanding is, a webservice gets "called" and returns Data or takes Data. But I require a constant exchange of sensor data between two devices in nearly realtime. I'm looking to implement something like a Multiplayer Online Game, how do they do such a thing? Or the Glympse service?
"Just because it's called GameKit doesn't mean its uses are limited to games. Any data you want to pump through that connection is fair game"
How true. The name GameKit is such a terrible misnomer, which very unfortunately diminishes it's significance, there are so much in this kit that you can do to develop serious apps.
The way I'd approach it is to create a "server" out there on the net, that would run some application (like a CGI script) to collect the data (store it, in maybe a database) - then allow the remote device to query it.
This means that every device has a "well-known service" which they are connecting to - potentially "logging into" - and selecting the data from.
For example, each "client" could push their "vessel name" and GPS location. The CGI script on the server would just put these in a MySQL database - as simple table containing "Vessel name" and "Location".
Alternativiley, clients could query and "pull" GPS locations for a specific vessel name. As simple CGI script that would take "Vesel Name" as a value, and send a MySQL query to the database to return the "Location". It could send the location (and vessel name) back in XML format.
The iPhone client could user NSXMLParser - or even a JavaScript "AJAX" client could use it's own inherent XML parsing capabilites to send a request for one (or more) vessels, and receive the results.
What you don't want to do is to have each client have to speak directly to each other client. This will get you into trouble with firewall rules, and mess up when you try to scale many-to-many communications.
If your devices are both running iOS, you can use the peer-to-peer connectivity functions in GameKit for this. There's a pretty good question and answer about that here.
Just because it's called GameKit doesn't mean its uses are limited to games. Any data you want to pump through that connection is fair game (so to speak).
You may use XMPP protocol to send/receive any xml data in almost realtime.
You will need to create chat room and every XMPP client (your app) will just need to login to that room. Message that is sent to the room will be delivered to every XMPP client.
Info on protocol and public servers can be found here: http://xmpp.org/
Good book on XMPP: http://download.cnet.com/XMPP-The-Definitive-Guide/3000-20412_4-75114351.html
Link to free iOS XMPP library can be found here: iOS messenger SDK

How & where to set up DB Server and communicate with iPhone

I'm working on iPhone app that will let users upload/download photos to/from a DB server along with some data associated with each photo.
While I do have experience with iPhone programing, I do not have much experience with DB and server side programing.
Does anyone have any tips on what would be the easiest way to set up DB server and handle requests and responses coming from the iPhone. This server may be potentially required to handle large amount of traffic and preserve data integrity. Several iPhone users might be attempting to upload and modify data associated with each photo at the same time.
I'm thinking of opening a hosted server account so I don't have to purchase hardware and run it from home. Any tips on a company that provides quality and affordable server and DB hosting would be much appreciated.
If you know some Python or Java, you could take a look at Google AppEngine.
It is designed to scale and the entry costs are very low (i.e. free).
You do not have to worry about any infrastructure hosting as it is all provided for you.
The only catch is that it is:
Harder to get data out of the platform if you decided to move off it to another system
Does not support push notifications (However there are a lot of push notification providers out there you can hire)