If I am developing an iPad app (the "Server") which needs to communicate with up to 4 iPhone/iPod Touches (the Clients) how can I manage this?
The two apps will be separate. Should I create 4 GKSessions for each of the iPhones? Should I have 1 GKSession which connects all 5 devices, and if I do, will each iPhone be able to "see" the others (Ideally, this shouldn't happen as it will keep things simple)? The apps will together be a bit like the Scrabble app for iPad (not in functionality, but in idea). How should I manage this?
Thanks in advance, and please comment if you need more information.
You should create a single session on the iPad, advertise it as a Server, and look for that session from each iPhone in client mode. The iPad should keep an array that has each peerID that is connected to it, most likely connected to or as part of some kind of array of controller or player objects. Since each iPhone is set to be a client, they only will be able to see the server session being advertised by the iPad, not the client signals coming from the other iPads.
If you want an iPhone to be able to signal another iPhone, you can pass out the array of peerIDs to each iPhone through some kind of messaging object, which will allow any particular iPhone to send a message directly to another iPhone.
I'm doing something similar with 1 or 2 iPads and up to 10 iPhones or iPad touches. With 2 iPads the game board gets expanded, and it allows more than 5 players.
Related
I mean two iPhone devices should be connected with Bluetooth or WiFi and the UI of the one device should be extended to another iPhone device(not sharing the screen). Do we have the way to do this in iOS?
Bump API is the best example and will be useful to you to connect two devices(IOS/Android) and transfer data between them.
Lets consider that I am connected to internet through 3G in my App. When a wi-fi hot spot seems to be appearing, can I programmatically switch to the wi-fi. Is this vice-versa condition possible?
iOS does this automatically by itself!
If no known WiFi network is found, it uses cellular data. If it finds a known WiFi-network, it connects to and uses that network instead.
If any WiFi-network is found, and your application requests access to the internet, iOS (usually) automatically presents an alertView and lets the user log in to a WiFi-network. If the user does not log into a WiFi-network, it stays on the 3G-network. When iOS 7 comes, iOS may connect to Hotspot 2.0 networks automatically as well.
Apple keeps individual apps on a tight leash, and so they do not let apps control things like this.
Is there a way to create a background app( once this is available on the iPad ) that can detect when your iPhone is close by? So I'm thinking that it would require the use of bluetooth. I'm thinking you could use this for syncing and such.
Ignoring the aspect of backgrounding (which isn't really what you were asking about in totality):
The way this would work on a running application is that both devices would need to have the application running. Then, they would both have to register themselves through Bluetooth using Bonjour/GameKit.
With traditional bluetooth iPhone/iPad games, the game checks bluetooth and displays local bluetooth players, and then the user can select another player.
Your application would retrieve that list of local bluetooth iPhones, and compare the device name to the device name which you have determined to be your iPhone.
Here is some: GameKit Documentation.
You can do this with two actively running apps. But backgrounding these apps... of course: NDA.
Here's the situation, I made a game that use GKSessionModePeer to do the multiplay mode, but the problem is happened when I use three iphones, just call them A,B,C
when A and C searched B,they choose B at the same time, then the screen change to the waiting for apply page,
at this moment,problem happen!!!!!
A and C start the game suddenly with no connection from each other ,B's screen show "Do you accept the connection" page, after a second A and C lost connection, what's happen???
I want iphone would accept connection one by one, A and C will not start the game suddenly,
what should i do???
Can anyone help me???
According to the GameKit framework reference:
Game Kit offers your applications the ability to create Bluetooth connections between two devices.
http://developer.apple.com/iphone/library/documentation/GameKit/Reference/GameKit_Collection/GameKit_Collection.pdf
Using GameKit to setup a game for more than 2 players won't work. You'll need to use another solution, such as one of the devices hosting a server and using a wifi network.
I'm new to developing applications for the iPhone and iPod touch. Is it possible to communicate directly between 2 devices in the same room by using WiFi or perhaps even BlueTooth on the iPhone?
I've seen a demo of a fire application where one iPhone "lights" other iPhone when they get close to each other. How is this accomplished?
The point of all this is that I am exploring the option of developing a game that you can play with another person in the same room.
The iPhone supports Bonjour based service discovery and several applications take advantage of this to do things like syncing with a PC on the same network. Explore the samples and guides in the iPhone SDK. WiTap and BonjourWeb are good examples to start with. NSNetServices and CFNetServices are the APIs you'll be dealing with for Bonjour
iPhone - iPhone communication can also be accomplished over bluetooth using GameKit.