chooseBestHostingPlayer(completionHandler:)
Determines the best player in the game to act as the server for a client-server topology.
Declaration
func chooseBestHostingPlayer(completionHandler: @escaping @Sendable (GKPlayer?) -> Void)func chooseBestHostingPlayer() async -> GKPlayer?Parameters
- completionHandler:
The block that GameKit calls when it completes the request.
The block receives the following parameter:
playerThe player with the best estimated network performance, or
nilif GameKit couldn’t determine the best host.
Mentioned in
Discussion
This method estimates which player has the best network connection using a variety of metrics such as bandwidth, latency, and network reliability. Use this method to choose the player that acts as the server when you implement a client-server topology on top of the match’s peer-to-peer connection.