I have a GKMatch game with two players where I send data from one player to another with the match.send().
As I understand in a peer to peer match, without a server, one of the players would act as a host, from whose device some of the game logic would be determined.
What I cannot figure out is how to set a player to be host for a game, as I cannot see any helping functions from GameKit other than chooseBestHostingPlayer(), but that return is optional so what would be a guaranteed way to determine host?
Also, after host is determined would I still use the same sendMethod such as match.send(), to update game state, then just check to make sure only send it if the player is host?
Any clarity on this topic would be highly appriciated, thank you.
chooseBestHostingPlayer()is indeed just a helper to find the player with the best network connection. You don't have to use this function.You can use your own way of deciding who is the "host" or "server". For instance: by throwing dice
An example of this can be found here: https://www.kodeco.com/2485-game-center-tutorial-how-to-make-a-simple-multiplayer-game-with-sprite-kit-part-2-2 (it's old Objc code but the mechanism is explained).