Any sample project that shows how to use the gamekit (server-client model) WITHOUT (!) A GKPeerPickerController and more than two devices?

Is there any sample project that shows how to use a gadget without gkpeerpicker? And is there a sample that uses bonjour (but without any internet connection and without a wireless router)? Some information (for both projects):

  • bluetooth only (bonjour for another project)
  • more than 2 devices (if possible)
  • client server model (how to make it work)
  • send / receive data
  • the server can decide whether it is "visible" to other "potential clients"
  • show the “detected” devices in the table view → if the user clicks on the tableview cell (the name of the device, for example, “Tom iPod Touch”), he will pair, but the other user must accept the connection (UIAlertView), and if he agrees, they will pair
  • show all connected peers (connected to server) in uitableview
  • throw out a few peers (only the server can strike others) (this should be easy to implement. Just send a special package to the client with a line that says "AVOID YOURSELF" that he will kick himself).
  • invite other clients (in search) (in fact, this is not necessary, but it would be great):
  • Let clients / server move objects (physical objects in box2d (cocos2d)), and each client should show exactly the same simulation on the screen.

After using Google for several hours, I think that there is no sample project (s) that shows these "features" above. Could someone do this maby? Please do not tell me any theory. I read so much, but a sample project (or more and more for the bonjour version) with code comments would be great!

Edit: I will probably add a little generosity to this;). Currently I can not;)

Thanks so much for reading :)

cocos2dbeginner

+4
source share
3 answers

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, especially Apple's witap example .

One note: you cannot switch from bluetooth to bonjour. bluetooth is the way to communicate, bonjour is the way you communicate. Therefore, you will need to do bonus broadcasts on the one hand and connect to each other. Bonjour took care of bluetooth in the Apple API, it should "just work." See more details.

This apple page not only contains the concepts of games, but also indicates the names of the methods that you will use to get your tasks performed, even if you do not want to go through the provided interface that Apple has with GameKit.

Here , here , here , and here are links for more complex web designs. As long as you do not perform complex tasks with sockets, I like it personally, it makes things very simple.

Hope this helps.

+2
source

I highly recommend the Ray Wenderlish page. There is a tutorial for Gamecenter networks that matches some of your needs. http://www.raywenderlich.com/3276/how-to-make-a-simple-multiplayer-game-with-game-center-tutorial-part-12

According to your pseudonym: There are many useful tutorials with high quality. Go to http://www.raywenderlich.com/tutorials for a list.

+1
source

Apple itself has demos that show Wi-Fi connections using GKSession and Bluetooth using GKPeerPickerController. If you need 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 where you want the collector to appear after you instantiate the collector.

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.

GKRocket code (using GKSession and tables) is much more complicated, but GKSession automatically uses bluetooth if there is no wifi coverage. Given that you will need most of the GKSession code in your project for working with Wi-Fi, I think it’s easier to forget about peerPickerController if you don't want only Bluetooth.

In the end, Apple will definitely add the necessary methods and properties of peerPickerController to handle Wi-Fi, but at the moment this is the GKSession you need.

Hope this helps.

0
source

All Articles