Reputation: 2217
is there any sample project that shows how to use gamekit without gkpeerpicker? And is there any sample that uses bonjour (but without any internet connection and no wireless router)? Some informations (for both projects):
After using google for some hours I think there's no sample project(s) that shows these "features" above. Mayby someone could make one? Please do not say me some theory. I read so much but a sample project (or more and another for the bonjour version) with code commentary would be great!
Edit: I will probably add some bounty on this ;). Currently I can't ;)
Thank you very much for reading :)
cocos2dbeginner
Upvotes: 4
Views: 3870
Reputation: 1128
Apple themselves have demo projects that show wifi connections using GKSession and Bluetooth using GKPeerPickerController. If you wanted a peerPicker and an option for both I think you need to use a peerpicker controller to give the user a choice. Use this code at the point you want the picker to appear, after you have instantiated the picker.
picker.connectionTypesMask = GKPeerPickerConnectionTypeOnline | GKPeerPickerConnectionTypeNearby;
Then if they choose wifi use the code from the GKRocket project in the iOS Sample Code Library. If they choose Bluetooth then use GKTank.
The GKRocket code (using GKSession and tables) is much harder to follow but GKSession automatically uses bluetooth if there is no wifi coverage. Given that you will need most of the code for GKSession in your project to handle wifi I think it is easier to forget about peerPickerController unless you only want bluetooth.
Eventually Apple will surely add the necessary methods and properties to peerPickerController to handle wifi, but for the moment it is GKSession you need.
Hope it helps.
Upvotes: 0
Reputation: 4285
I'm not going to write this for you but I can help with some information to get you started. There are many examples that show some of your features, particularly Apple's witap example.
One thing to note, you can't go from bluetooth to bonjour. bluetooth is the method of communication, bonjour is how you communicate. So you'd have to do bonjour broadcasting on one side and connecting on the other. Bonjour over bluetooth is taken care of in Apple's API, it should "just work". See this for some more info here.
This page from apple not only has gamekit concepts you are looking for but it also tells you the method names you will be using to get your tasks done, even if you don't want to be going through the supplied UI that apple has with GameKit.
Here, here, here, and here are links for more bonjour networking samples. As long as you're not doing complex tasks with sockets, I like this personally, it makes things very simple.
Hope that helps some.
Upvotes: 2
Reputation: 7178
I highly recommend Ray Wenderlichs page. There is a tutorial for Gamecenter networking that matches some of your requests. http://www.raywenderlich.com/3276/how-to-make-a-simple-multiplayer-game-with-game-center-tutorial-part-12
According to your alias: There are many more useful tutorials with a high quality. Go to http://www.raywenderlich.com/tutorials for a list.
Upvotes: 1