Как игрок, программно использующий GameKit, сообщает, что хочет присоединиться к матчу? - PullRequest
0 голосов
/ 17 апреля 2020

У меня проблемы с поиском в стандартной документации GameKit информации о том, как игрок объявляет, что хочет присоединиться к какому-либо матчу? Есть документация о том, как создать матч и пригласить ожидающих игроков, но я не могу понять, как игрок рекламирует присоединиться к матчу и стать этим «ожидающим» игроком?

Вот ссылка на документацию Apple https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchmakingwithGameCenter/MatchmakingwithGameCenter.html

Ответы [ 2 ]

0 голосов
/ 17 апреля 2020

Вызов findMatch на GKMatchmaker, вероятно, сработает:

https://developer.apple.com/documentation/gamekit/gkmatchmaker/1520777-findmatch

    // Auto-matching or invites to find a peer-to-peer match for the specified request. Error will be nil on success:
    // Possible reasons for error:
    // 1. Communications failure
    // 2. Unauthenticated player
    // 3. Timeout
    // Note that the players property on the returned GKMatch instance will only contain connected players. It will initially be empty as players are connecting. Implement the GKMatchDelegate method match:player:didChangeConnectionState: to listen for updates to the GKMatch instance's players property.

    open func findMatch(for request: GKMatchRequest, withCompletionHandler completionHandler: ((GKMatch?, Error?) -> Void)? = nil)
0 голосов
/ 17 апреля 2020

Я полагаю, что предоставление invitation handler является ответом:

https://developer.apple.com/documentation/gamekit/gkmatchmaker

To receive invitations from other players, your game must provide an 
invitation handler. After your game successfully authenticates the local 
player, it should immediately set the inviteHandler property. The invite 
handler is called immediately if your game was launched in response to a 
push notification.

РЕДАКТИРОВАТЬ: ОТСУТСТВУЕТ, это свойство явно УСТАРЕЛО, так как iOS 7

...