iOS Online Game w/o Server? - iphone

I've made an iOS game that works over both Bluetooth and bonjour. It works great both ways, but I'd really like it if players could play with eachother with any Internet connection, be it edge, 3G, or different wi-fi addresses.
The catch: I don't have the resources or knowledge to set up dedicated servers or anything like that. It seems that surely GameKit has something in it that will let me do this, but despite spending dozens of hours over the last week figuring out how to use it, I've found nothing.
So, does anyone have ideas for solutions? My game is just one on one, if that makes it any easier.

Why don't go through the Game Center with GameKit?
Apple provides all the infrastructure to play all around the world via their servers (in 3G or Wifi). With the Game Center you can play up to 4 players (so in your case there is no problem), it's free, you don't have to manage any server, there is a mechanism of invitation between friends, and many more.
The logic of your game stay in the client side, so it'll be same design as your actual game (expect for the API I think).
You can find all information on the official documentation here.
If you want, there is a very tuto on the ray wenderlich's blog (but it uses the cocos2d framework instead of the CocoaTouch).

Yep, try GameCenter with GKMatch - works really well if game doesnt need to send tons of data. If you make additional layer between your app and GKMatch and GKSession, you can use both transparently (so your game supports local AND global multiplayer). Tested, it works

Related

Roll your own Multiplayer iPhone setup?

I've been looking into the various options for implementing multiplayer (internet) in iPhone games. Game Center, OpenFeint etc are obviously very good, stable and feature-rich. But I can't help thinking my needs are a lot simpler than what they provide.
If I wanted to put together a simple 2d tank game, could I not just..
setup a mysql server on the web, with some get/set php scripts to actas 'web services'.
when you open the game, a call is made to the server, to log that you're 'available'.
when you select Play, a call is made to retrieve a list of 'available' IP's.
you select an opponent, remote IP is stored locally.
game starts, UDP handles the data between your IP and your opponent's IP.
..or would that never work? apologies, I'm very much a n00b at gaming/networking dev!
thanks in advance!
In addition to the complexities that dtuckernet points out, there are few other things to consider:
You need to think about the cost of running and supporting the web server. Can you maintain the same or better uptime than Apple and OpenFeint?
GameCentre promotes games that support it. The App Store adds an icon, and Game Centre itself lists games that your friends own. Don't underestimate the effect of free advertising!
Even if the code it easy (which I suspect isn't true), why take the risk of developing your own when there is well-tested code available for free?
Incidentally, depending on your requirements, you may want to use a hybrid approach. For example, Game Centre has a maximum of four players per game when Apple hosts it. You can find players using GC and then run the games itself on your own server.
That would certainly work, but implementing this can be a bit harder than it seems initially. You have to handle things like NAT/Firewall traversal and if you are using UDP you need to implement some type of a heartbeat to ensure you know when devices have disconnected (and handle it accordingly).
In most all cases, you would be better off working with a solution that already has these problems solved.

Share saved game data via game center?

I'm trying to figure out if game center is the right tool for me. Here's my situation:
I'm building an app which allows users to create their own musical compositions. I plan to make the compositions exportable and loadable via text file (xml or json format, probably). I'd like to allow users to share their compositions with friends. It seems to me that game kit is the default social network for iOS, so it seems worth looking at. However, the social aspect of game kit seems to be designed mainly for real-time, simultaneous play. Is there any way to share data with friends in a non-realtime way via game center? Is there even a way to send game center contacts a message?
If you look at the documentation for peer-to-peer networking in GameKit, you will probably find exactly what you are looking for, with a tiny exception. It is only for wifi/bluetooth connectivity.
The way I would go with your description is a private server that hosts the compositions. If you are familiar to Java and/or Python, I'd recommend using Google App Engine for the server. That would make the headache a little bit less.
You can use GameKit too, but as you describe it, it's more for real-time communication.
If you implement invitation handlers, you could "invite" another player to receive the composition, but if they reject you will have to retry manually at a later point.
The contents of what you sent over an open "GameKit connection" can be "anything" you like, stuffed into a NSData object, so there is no limits there.
I hope this helps you a tiny bit in the right direction, good luck!

How the game will search for other online users and will display the list of all users?

I am asking this question as a small part of my question series regarding game programming .
Refer this question as the main one .
Now suppose I want to develop one small board game on iphone that is multiplayer . so how it will handle how many users are online and displaying them .
Suppose it is an online multiplayer casino game .
Then suppose it have to show currently playing tables and users on them .
So what can we do in iphone to do this sort of thing .
Thanks .
You're essentially asking what is referred to as 'matchmaking' in PC and console games.
The notion of displaying all currently online players or active matches is an early one in online multiplayer gaming, and I think it's seen its time. Instead, try and offer your players two options: Play with your friends or play against people of your skill level.
Showing someone a complete list of tens/hundreds or even thousands of games/players is just going to overwhelm them. People are much more comfortable knowing they're playing against people they know (and trust not to be unsportsmanlike) or at least that they're playing against someone of comparable skill level. These 2 concepts are often called 'buddy based matchmaking' (or friend lists) and 'automatch' or skill based matchmaking.
Unfortunately, from what I've seen in the GameKit framework, neither are fully supported, at least as far as playing on non LAN connections. You're going to have to either develop that yourself (and very few iPhone developers are going to have the resources to create and host it), or see if someone like OpenFeint, ngmoco (plusplus), Chillingo (Crystal) etc match your needs. OpenFeint seem to be talking about matchmaking on their site and plusplus offer buddy based challenges. The OpenFeint signup process is the easiest and you get access to their SDK right away for development without prior approval.
Now here's one final thing to consider: smaller games aren't going to have the player base to have enough concurrent players around so that everyone will always find a suitable match at any time of the day/week. Unless you have promotion and publisher backing, or a breakaway hit, picking an automatch based solution is not your best bet and shouldn't be your only mode of matchmaking. Ideally your game should allow for some turn based form of game play, so you can play asynchronously. That model has worked great for games like Words With Friends.
You need a server, you gameclient will contact it to get assigned to a partner. This is call matchmaking (google it to learn more).
I think there are OpenSource solutions (or at least frameworks) for this. But I don't know them. I know however Exit Games Neutron and Photon and I think there are free licenses for private / educational use.

GKPeerStateAvailable for non existing peers?

used this website for the long time to find answers, now need to ask on myself! :)
I have implemented multi player for my game using GKSession and client/server approach, not using peer picker (up to 4 player allowed).
I have one big problem which I can't find solution for.
If you disconnect/reconnect server peer quickly enough, client peer will "remember" that host and will show it in the list of all available peers permanently, only turning wifi/bluetooth off resets this.
So if I do this 5 times in a row, my client will show 5 available hosts with the same name!
Anyone had experience with this? Any idea of workarounds?
I should note that requirements for my game is iPhone SDK 3.0 for Bluetooth and 3.1 for Wifi as GKSession supports both now.
I have a similar problem. In fact I event get peers listed who are not even currently playing the game. Even more so, peers who are not acting as server are listed. I am wondering if there is some behind the scenes caching going on.
I'm thinking about implementing some kind of timer with visual feedback to show the disconnect progress, ideally to prevent this situation. It seems like in general there is a bit of time delay involved with connecting/available and disconnecting/unavailable. It might be better to code the interface to take these time delays into consideration, though I'm not sure exactly how.

which features do you look forward to the most in iPhone SDK 3?

Which of the new features are you looking forward to the most in iPhone SDK 3.0?
Is it one of the main advertised six new things, or something smaller? Something in the "1,000 new APIs", perhaps?
Phone to phone communication via bluetooth seems like it will terribly useful for some apps I am writing. No longer do you have to input all the data you want to store yourself, you can share some of it with other iPhone users.
not really a feature, but the best thing about developing the iPhone SDK further is the great frameworks that arise. there are some really, really great frameworks out there already (like the Three20 project) which will become even better with the new 3.0 SDK.
my real excitement will take over once they let us run background processes. maybe in 4.0?
Video! The ability to write decent tools for mobile video uploads is a big draw.
MapKit by far will bring the biggest change sweeping across the app space.
My personal favorite is that we can finally easily track upload progress of large files (like images).
I really, really want to see fixes in the camera API so that it isn't either broken (2.2.1) or forcing a switch to portrait (3.0).
Apart from that, the most useful features to me are:
push notifications. Great for making an app more sticky - you can let the user know that something of interest to them has happened.
CoreData - I've been using a third-party SQL layer, but it's a little buggy and no longer supported.
Peer-peer bluetooth, as the poster above said, is also useful for local data exchange.
And the least useful? Cut and paste. I actually want to disable it in my app (to discourage people from copying content) - and it doesn't look as though you can (yet).
Bluetooth phone-to-phone communication with GameKit will enable a host of currently impossible applications. Multiplayer games with no WiFi network needed and data exchange between two phones are obvious use-cases.
I'd also like to see - not currently included in the betas - a decent camera API that allowed us to customize the appearance of the capture screen, and as another poster said, have it work properly in landscape and portrait mode.