Protocol: GKMatchmakerViewControllerDelegate

Overview

A class implements the GKMatchmakerViewControllerDelegate protocol to receive notifications from a GKMatchmakerViewController object. The delegate is called if a new match has been successfully created, if the user cancels matchmaking, and if an error occurs. In all three cases, the delegate should dismiss the view controller.Called when the view controller encounters an unrecoverable error. (required)Called when a peer-to-peer match is found.Called when a hosted match is found.Called when a player in a hosted match accepts the invitation.Called when the user cancels the matchmaking request (required)

Instance Method Summary (collapse)

Instance Method Details

- (Object) matchmakerViewController(viewController, didFailWithError:error)

Called when the view controller encounters an unrecoverable error. (required)

Parameters:

Returns:

- (Object) matchmakerViewController(viewController, didFindMatch:match)

Called when a peer-to-peer match is found. This method is called when the view controller’s hosted property is NO. Although optional in the protocol, if your game attaches a delegate to the view controller for a peer-to-peer match, the view controller expects your game to provide an implementation of this method.

Parameters:

Returns:

- (Object) matchmakerViewController(viewController, didFindPlayers:playerIDs)

Called when a hosted match is found. This method is called when the view controller’s hosted property is YES. Although optional in the protocol, if your game attaches a delegate to the view controller for a hosted match, the view controller expects your game to provide an implementation of this method.The view controller returns the list of players to your game by calling this method. Your game is responsible for connecting these players to your own server and then using that server to relay messages between the players.

Parameters:

  • viewController (GKMatchmakerViewController)

    The view controller that performed the matchmaking.

  • players (Array)

    An array of identifier strings for the matched players.

Returns:

- (Object) matchmakerViewController(viewController, didReceiveAcceptFromHostedPlayer:playerID)

Called when a player in a hosted match accepts the invitation. After a player accepts an invitation, that player’s device should connect to your server. Once the connection is established, your game should call the view controller’s setHostedPlayer:connected: method to update the player’s connection status.

Parameters:

  • viewController (GKMatchmakerViewController)

    The view controller that accepted the invitation..

  • playerID (String)

    The identifier of the accepting player.

Returns:

- (Object) matchmakerViewControllerWasCancelled(viewController)

Called when the user cancels the matchmaking request (required)

Parameters:

Returns: