Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make connection over WiFi when working with Gamekit?

I want to make connection between two devices over WiFi using GameKit. Apple's documentation says

If an Internet connection is chosen, your application must dismiss the peer picker dialog and present its own user interface to complete the connection.

This is what i do

- (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type
{
if (type == GKPeerPickerConnectionTypeOnline) 
{
    picker.delegate = nil;
    [picker dismiss];
    [picker autorelease];

    [alert setTitle:@"\n\n\n"];
    [alert setMessage:@"Looking for other iPads, iPhones or iPod touches..."];
    [alert addButtonWithTitle:@"Cancel"];

    UIActivityIndicatorView *progress   = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    [alert addSubview:progress];
    [progress startAnimating];
    [alert show];
}
}

Ok, i have presented my own interface. And what next? How do i connect? How to start looking for peers?

like image 523
Andrey Chernukha Avatar asked Nov 04 '22 22:11

Andrey Chernukha


1 Answers

This tutorial builds peer to peer card game using Gamekit and either Bluetooth or wifi. (link updated)

like image 182
James Stewart Avatar answered Nov 15 '22 05:11

James Stewart