How can I implement multiplayer in my iphone game? - iphone

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.

Related

iPhone peer-to-peer voice chat

I see that Game Kit allows you to develop games with voice chat.
I want to build a more general, peer-to-peer voice chat application, that does not have to live in the Game Center. So a couple questions:
1. What peer to peer system/technologies could be used for this?
2. If I wanted to allow voice chat with a Flash client (i.e. iPhone app <--> Server <---> Flash client on PC) would options for 1 work for this?
I have some experience with RTFMP for Flash to Flash client chat, and no iPhone dev experience, so just want to test out some ideas.
Maybe one idea: build using the Ribbit Platform - they have both Objective-C and Flash SDKs, but this looks more like traditional\SIP calling.
Anyway, would appreciate anything that points me in the right direction.
Thanks.
Now that flash has access to raw Microphone data, you could roll your own client and server; yet, since, currently, it doesn't have UDP sockets in AIR for mobile, you would be forced into considering audio quality vs lagg with even tighter restrictions then usual.
You can now roll your own native extension to make this work; yet, I am assuming you want something that only requires coding in AS3.
Therefore, considering your restrictions, the only real bet would be to use Flash's built-in communications capabilities (e.g. RTMP).
With the above being said, there are opensource alternatives to the array of Adobe's own flash communication servers:
the red5 server, and rtmpd.
IMHO Ribbit's services are kind of pointless.

How to do peer-to-peer communication in an iPhone app?

I'm trying to write a simple chat application for the iPhone (as an experiment). Is there a simple way for two devices to discover each others' IP addresses, and given the addresses is there a simple API or protocol that would let me send text messages back and forth?
I've investigated SIP (specifically Sofia and eXosip), but these tools exist as C libraries and are beyond my current ability to port them to the iPhone.
Update: I'm trying to connect two devices over the Internet (i.e. not over Bluetooth or a local wireless network, which is what GameKit does).
You're going to need a server that provides the match making service. Game Center makes this pretty easy, but your users will have to have Game Center accounts.
Alternatively, you can set up an XMPP (formerly Jabber, it's what powers Google Chat) server (I've never done this, but there are several available) and use the XMPP Framework for Cocoa. There are instructions for using it in iPhone apps here.
I'm sure there are other chat servers and client source also available. IRC and Mobile Colloquy come to mind.
Finally, you could write your own server using your favorite server language / framework. This isn't too hard (I've done it myself), but it's far from what I'd call simple, and I wouldn't use it for a production system.
There is support for exactly this kind of ad-hoc peer-to-peer networking in GameKit. Have a look at the second half of the GameKit documentation for details:
http://developer.apple.com/library/ios/#documentation/...
NSNetService is a good option.
Take a look at WebRTC Datachannels. WebRTC is a newer option with native iOS support a standard that is still being finalized, but it is more flexible should the iOS app need to communicate with browser or even android peers

peer-to-peer multiplayer game with xmpp

I'm fairly new to multiplayer games. I have made a few for my own fun, but nothing profound.
Anyway, I want to make a game that is very cross-platform. The clients would be connected with their facebook accounts on the devices I release the game for (most likely computers (via flash), iPhone, and android). I am a solo developer on a shoestring budget (actually more like no budget). So, I want to make the game with a peer-to-peer connection. I would like to avoid using a client/server setup because of the cost to maintain a server. The problem I am running into is there is no way to connect peers over the internet, and the game is not meant to be played over a local wifi.
So, I have an idea. Can I use facebook's built in xmpp chat to send the game's multiplayer communication over the internet? I have head of xmpp being used for multiplayer games before. Does anyone have any other ideas? I understand that xmpp can be connected peer-to-peer, but can it be done over the internet somehow. I don't want the users to have to mess with router settings to play.
Thanks for your help!
The main problem in P2P systems are NATs and firewalls. Firewalls can be locally opened, NATs cannot in 99% of the cases. In the IPv6 world there will be no NATs, so P2P will be free for all.
Now you want to use Facebook's XMPP APIs for P2P multiplayer. Well... Facebook's XMPP is practically client/server because of the above reason. All Facebook's APIs do is to hide the transport layer to applications, meaning that you can send messages to "another user" while they actually transit through Facebook server. Skype is another example of P2P+server environment. If two users stand behind a NAT, it automatically uses a proxy server.
This is mostly the same with FB's XMPP, so you can go with that, unless your facebook users will see lots of strange messages in their chat window :)
I think you cannot build a multi-player game just by using facebook jabber servers. You will need to have a custom jabber component sitting at your own server to enforce your game business logic on the xmpp packets transferred between the game users.
This will (probably) involve writing custom Jabber Component Protocol XEP-0114 and Bosh Connection Manager component at your end. If you are looking to use PHP for developing your application you can have a look at Jaxl library (XMPP component and client library in PHP)

Simple Game Server

I'm looking for a simple game server for an iPhone game I'm creating.
The game is turn based, so I just need a way for players to find other players,
and then have the server gather and send out turns.
It's a simple two player card game.
If you have ever seem the with friends app.. ( Chess with friends, Words with friends ) that is the type of server I'm looking for.
Any suggestions on free or low cost software I can use??
If you would like to integrate OpenFeint, there is a turnbased multiplayer component you can take advantage of. No independent server required, with a simple and capable API ready for you to use.
http://www.openfeint.com/ofdeveloper/index.php/kb/article/000074
Here is a similar open source game. It is a two-player game server.
It can be hosted on Google App Engine.
For something scalable you can use SmartFoxServer or Google App Engine if you want to role your own scalable backend on the cheap. Integrating with Apple Push Notification could be done with Urban Airship
You can use Apple's GameCenter's built in Match making feature to create turn based multiplayer games.
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchesandVoice/MatchesandVoice.html

Getting started with Server applications

I have an iPhone game (Combination), and in the next version I would like to set up a server, where users (via the app) can submit which levels they have completed, and see how other users are doing. At this point I don't intend that users will need usernames and passwords, just a simple submit data, get back data.
I know very little about server-based language and databases, but I've heard lots of horrible things that can happen if you get it wrong. What would be the best system to design a simple, lightweight, secure database in?
How about having a look at Onyx Online or OpenFeint?
Onxy Online is from the makers of Trism, and they say, "the XBox Live Arcade ecosystem brought to the iPhone". I wrote this kind of system into Trism as a case study, and it's been a complete success. Since Trism launched in July, we've been hard at work adapting this online code for use in any iPhone game, and the results are stunning. What we're going to do is allow any developer to insert the Onyx code into their game, which will instantly enable online scoring, achievements, leaderboards, and customized forums."
OpenFeint is from the developers of Aurora Feint. From the press release:
"OpenFeint allows any iPhone game to add player profiles, buddy lists, walls, newsfeeds and real-time chat rooms allowing the game to build a real community around itself with ZERO operations overhead and minimal development time. OpenFeint consists of a server and a client. The OpenFeint Server is fully compatible with Google’s OpenSocial REST API and will be accessible through the OpenFeint client code library and sample UI code from Aurora Feint Inc. Indie developers do not have to operate the servers, which will be hosted Aurora Feint’s data center.
In a first for iPhone games, iPhone game developers will have the ability to reduce over 2 months of development work to 1 day, and completely eliminate back-end server operations, while offering their players an extensive set of customizable social and community building features:
Profiles: Players can upload an avatar photo or take one with their iPhone camera.
Walls: Each player gets a wall where other players can leave comments and view wall-to-wall conversations
Asynchronous Real Time Chat Rooms for meeting other players, sharing tips, strategies and experiences within each game community
Buddy List: Players can friend other players within their community or across the iPhone gaming community
Newsfeeds: Players can keep in touch with all of their friends’ activities (wall comments, actions in games, befriending people)
Global Community Chat Rooms for players to discuss recommendations, tips, and reviews of other games on the iPhone"
Have you used Java/C#/Perl/Python any other "server side language?" Are you going to be hosting the server-side yourself, or are you looking at hosting companies? Your decision might come down to how you intend to host your server-side stuff, and what capabilites your hosting company offers or what you are comfortable with.
Java or C# are really powerful server-side languages, but hosting these can take a little more work (and money?).
Java might be a good starting point, because you can setup Tomcat yourself and try hosting some web-services. MySQL is a good database to start with, but there are even more lightweight database alternatives. There might be a bit of a learning curve with any of these.
Have you heard of ICE touch? ICE is a middleware for network communication and has a basic persistence support. It supports every major platform:
iPhone as a client
Android as a client
Objective-C Mac OS X as client/server
C++ Linux as client/server
Java [any OS] as client/server
C#/C++, Windows .NET (with Silverlight) and native as client/server
I evaluated it some time ago and was surprised about its maturity, good documentation and example code. They name Skype as one of their customers.
As a start I would recommend to have a look at their example chat application. You can run a Java server, connect with your iPhone, your G1 and your Silverlight client and have a chat. Pretty impressive interoperabilty!
Here comes the drawback: GPL (you cannot link against it without being GPL yourself) or commercial (individual pricing).
I would also recommend you to use an online database service such as Viravis , DabbleDB or Zoho Creator. Almost all of these kinds of services have required integration capability to work with such a client as Web, Desktop, Windows Mobile or IPhone.
Java/Javascript is the defacto combo for most developers because of the Java support for every platform. Java Script has more than a few "issues"
The rest of the herd uses .NET (with its attendant 100MB run time bloatware that changes every 9 months)
php,pearl,ruby etc are good for server side, but if you want to use code, the best solution is probably C/C++ (or similar) and CGI/FastCGI.
This allows you to write communication algos once and use them on both ends. Any encryption/compresssion sim same.