Multiplayer game in iphone - concept, strategy, design? [closed] - iphone

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to develop an online multiplayer game for iphone.
I have developed two iphone applications but they weren't games.
so This is my first game .
so Basically I know nothing about how online multiplayer games works on iphone.
I just want to know the strategy , beginner's precautions and other design elements that helps me in understanding multiplayer games in iphone .
e.g.: If there is an online casino game (not bluetooth) ,how the connections and sessions work between all players.How they manage turns , results .
EDIT
I have put these questions separately also as suggested by Brad Larson and ChrisF :
How the game will search for other online users and will display the list of all users ?
How one can request someone to join the game and then visible to other users ?
How the connection and session will work between players of a table ? (Sockets ?)
What sort of network programming is necessary as part of the server and client ?
please tell me how all these works ? ( Just concepts )
Thanks .

How the game will search for other online users and will display the list of all users ?
You'll need a server that returns a list of online players to your iPhone client is some kind of data format, maybe XML or JSON.
How one can request someone to join the game and then visible to other users ?
The easiest approach would be the person who wants to to join the game sends that command to the server, the server tells that other person they want to join. Wait for a response. If player two says "yes", returns to the server which forwards to the first player.
It's basically a series of commands sent to and from the server. This is how all multiplayer games work - for example the Quake engine sends very compact commands, as little as 4 bytes for things like "get me all players on a server". Given the flakeyness of the iPhone connection this would be a good model to copy, as the Quake networking code was designed for 56k modems.
How the connection and session will work between players of a table ? (Sockets ?)
The connection could either be a continuous stream (UDP would be best), or polling from the client. You'll need to consider scaling for both, as it's possible 100 people playing could bring your server to its knees.
The session will be dropped if one player loses their connection. Alternatively as it's turn based, each player can simply send a command when they're online and the other client picks this up when he's online - there's no need for session in this model, and the commands are stored on the server in a datastore.
What sort of network programming is necessary as part of the server and client ?
I'll broaden this out:
An in depth knowledge of byte and bit manipulation including bit shifting
A knowledge of creating and reading UDP packets
Network programming in C (Objective-C may simplify a lot of this)
The server: writing daemons on Linux, or services on Windows to listen for commands
A knowledge of SOAP, XML or JSON if you're not concerned with bandwidth and connection drops

One thing you might need is a server to store the game state as you can't guarantee that both (all?) players will be on-line at the same time. One of the things this would store would be whose turn it was.
Then when a player turns on his/her phone or starts the game they would see a message saying it's their turn.
You could use this server to store high scores and tables too.

Related

Multiplayers online game (MMO) | Architecture | Learning Path

I want to learn game development.
I'm coming from Web, Desktop and Mobile Applications.
where is no really REAL-TIME programming.
And all architecture templates and life cycles is very different.
Now I have 1 idea for game. I don't know if this will very good game, but for first game my main goal is - Get experience
My game is online game with 2 players.
The players has cards (like in Clash Royal) and will player release the card - game need to do something.
Now question is in Architecture....
In applications that I made - all business logic was on SERVER SIDE..........
But If i understand right - here is Game on Players phone do all business logic..and server is just "message provider" ??
The second question is - If I have to use online service (like Photon) or build my TCP/UDP server.. (Its not so hard and for first game I think I can do it by myself)
UPDATED:
The main question what is resources I need to read for get more information about type of Architectures in Game Dev?
Thank you for your answers.
There is no RIGHT ANSWER for your question, as there are many ways to do an on-line game, and everyone have their pros and cons, like:
Host & Clients, where one of the players is acting like a server.
Authoritary Server, where all the logic is calculated on one side, and then update the others.
If you are working on Unity I recommend you to look the different network api's over there: Photon, Unet...
You can use the server services that Unet provides, or build your own system.
But one advise: don't mess with physics on on-line games, will be punishing.

How can I start to build voice chat application iPhone? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 months ago.
Improve this question
I want to build voice chat application for iphone.
After surfing and searching i conclude that for making of voice chat app i have to use VOIP/SIP protocol.
So my question is that,
It's necessary to use VOIP/SIP protocol for voice chat? If YES then how can i use VOIP/SIP in my app? Is there any tutorial or blog which explain step by step implementation?
And if it's not necessary to use VOIP/SIP then what is the alternate way for developing Chat application ?
Thanks in advance.
It is not necessary to use SIP. SIP is one of the umbrella standards that enable you to create multimedia sessions of any kind, however with SIP you will also have to implement a number of other things - Offer/Answer model using SDP (Session Description Protocol), use a RTP (Real time protocol) for actual voice transmission, likely MSRP (Message Session Relay Protocol) for session oriented messaging and then possibly look at Presence and whole slew of standards under SIP/SIMPLE.
Now you don't have to do it all and it all depends on what you want to do and how many and what types of other clients and 3rd party servers you want to interface with.
Have a look at existing free SIP software and see what makes sense for you.
Alternatively have a look at XMPP which is more suited for chat and presence kind of requirements. Specifically look at Jabber and see if that makes sense.
You do not need to use SIP. For example, ConnectyCube video solution is based on XMPP for chat and signaling to establish the connection before the call and WebRTC standard for video calls. You can check code samples to see how they implemented it on iOS.
To try the solution you can register a free account. If it suits you, you can use their SDK to speed up the development.
The benefit of using a ready backend with SDK is also that you do not need to worry about setting up a STUN/TURN server for routing video calls. They have a shared one you can use.

Synchronization in multiplayer networked game?

Recently I have been working on a multiplayer networking app. I had successfully implemented the client server model using Bonjour services and NSStream objects. The two way communication has been done successfully.
The problem I'm facing is: the two devices running the app are connected via local wifi. There is a latency problem while sending the messages from client to server and vice versa.
Describing in brief:
It's a car racing game with at most two players.
One server and other client.
When client press the buttons a particular message is sent to the server telling which key or button was pressed. Then the server responds accordingly and make changes on the client's car on the server itself. These changes are not always the same. There is always a difference between the actual location of the car on the client's screen and that in the server screen.
Any ideas?
Welcome to the world of networking. :)
These are the classic difficulties with game networking programming. There's a lot of different techniques to overcome these issues.
This blog has great info on the subject and will probably help you out.
http://gafferongames.com/networking-for-game-programmers/
You may be specifically interested in this article:
http://www.gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking
Good luck!

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

Set up server for simple iPhone game

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