IT tutorials
 
Mobile
 

iPhone Developer : Creating an “Online” GameKit Connection

4/16/2013 9:40:39 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

In the GameKit world, “online” currently means any valid connection style other than Bluetooth. You might use a local WLAN network to connect to another device on the same network or connect through WWAN (i.e., the cellular service) or WiFi to a remote Internet-based host. GameKit takes you only so far as the dialog shown in Figure 1. By selecting Online, your user depends on you to create a custom connection to another device or service.

Figure 1. The Online GameKit connection means “bring your own networking.” (Please note that the Send button shown on the keyboard here is a standard Return key. In this recipe, data is sent as it is typed.)


You create this two-item dialog by supplying the online option to the peer picker mask. In all other ways, there’s no change in how you create and present a standard GameKit peer picker controller.

- (void) startConnection
{
    if (!self.isConnected)
    {
        GKPeerPickerController *picker = [[GKPeerPickerController
            alloc] init];
        picker.delegate = self;
        picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby |
            GKPeerPickerConnectionTypeOnline;
        [picker show];
        if (self.viewController)
            self.viewController.navigationItem.rightBarButtonItem =
                nil;
    }
}

Catch the user selection in the peerPickerController:didSelectConnectionType: callback. You can assume that if the user selected Nearby that all the handshaking dialogs are taken care of for you. Should the user select Online, however, it’s up to you to move things to the next step. You need to dismiss the picker and display the next stage of the connection task. Here, control passes away from the peer picker. 

- (void)peerPickerController:(GKPeerPickerController *)picker
    didSelectConnectionType:(GKPeerPickerConnectionType)type
{
    if(type == GKPeerPickerConnectionTypeOnline)
    {
        [picker dismiss];
        [picker release];
        [BonjourHelper sharedInstance].sessionID = self.sessionID;
        [BonjourHelper sharedInstance].viewController =
            self.viewController;
        [BonjourHelper sharedInstance].dataDelegate =
            self.dataDelegate;
        [BonjourHelper connect];
    }
}

As Recipe 1 demonstrates, almost no changes are needed from the BonjourHelper side of things. The Connect button on the navigation bar must point back to GameKit’s connect method, not to BonjourHelper’s. This ensures that users can finish a Bonjour connection and then move on to a Bluetooth one without restarting the application.

Recipe 1. Updating the Macro Code to Use GameKit’s Version of Connect
#define GBARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] \
initWithTitle:TITLE style:UIBarButtonItemStylePlain \
target:[GameKitHelper class] action:SELECTOR] autorelease]

if (sharedInstance.viewController)
    sharedInstance.viewController.navigationItem.rightBarButtonItem =
        GBARBUTTON(@"Connect", @selector(connect));


Additionally, you might think the Info.plist file needs a UIRequiresPersistentWiFi key set to the Boolean value of true. Avoid doing this. Instead, check for WiFi only when you are ready to attempt to create a WiFi connection, i.e., when the user clicks Online. GameKit Bluetooth connections don’t need persistent WiFi although standard Bonjour ones do. Don’t require your users to connect to a (possibly nonexistent) WiFi service when Bluetooth is sufficient for Nearby gaming.

 
Others
 
- Java ME on Symbian OS : Handling Transitions Between Foreground and Background
- Java ME on Symbian OS : Handling JSR Fragmentation
- IPad : Using Popular and Critical Apps - Using Bento
- IPad : Using Popular and Critical Apps - Using iTap VNC
- BlackBerry Development : Pushing Data to Internal Users - Browser Push
- BlackBerry Application Data Push : How the Application Data Push Process Works
- Windows Phone 8 : Controls - Data Binding (part 4) - Control Templates
- Windows Phone 8 : Controls - Data Binding (part 3) - Data Binding Errors
- Windows Phone 8 : Controls - Data Binding (part 2) - Improving Scrolling Performance, Binding Formatting, Converters
- Windows Phone 8 : Controls - Data Binding (part 1) - Simple Data Binding, Using a DataTemplate
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us