Instance Method

chooseBestHostPlayer(completionHandler:)

Determines the best player in the game to act as the server for a client-server match.

Declaration

func chooseBestHostPlayer(completionHandler: @escaping (String?) -> Void)

Parameters

completionHandler

A block to be called after the best player has been determined.

The block receives the following parameter:

playerID

The player identifier for the player with the best estimated network performance, or nil if a player could not currently be determined.

Discussion

Calling this method causes Game Kit to attempt to estimate which player has the best overall network connection using a variety of metrics such as bandwidth, latency and network reliability. Typically, you call this method when your game implements a client-server model on top of the match’s peer-to-peer connection. See Game Center Programming Guide.

When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. The completion handler is always called on the main thread.

See Also

Deprecated Methods and Properties

var playerIDs: [String]

An array of NSString objects containing the player identifiers for remote players in the match.

Deprecated
func send(Data, toPlayers: [String], with: GKMatch.SendDataMode)

Transmits data to a list of connected players.

Deprecated