Handling cancel in GKMatchmakerviewcontroller
Asked Answered
G

2

7

I am making a multiplayer feature to a game I made.

Everything is working, except when I am in matchmaking and both players are connected, if one person hits the "Cancel" button the other device gets no notice of the canceling.

On the other device it the words change to say "Disconnected" however none of the delegate methods are called.

How can I handle this?

Greenshank answered 1/6, 2015 at 6:57 Comment(0)
G
0

Unfortunately, there is not a method (that I know of, or could find with almost 3 months of looking into it) that is called when one person disconnects in matchmaking after they have begun to connect.

Therefore, the way I got around this is once the GameViewController is presented it waits one second and then calls a method to check to see if it is connected to someone else.

To do this I have it so once the game begins each player sends the other player a random number (used to determine non-related settings later on - such as who gets to go first). When it calls the method to check to see if it is connected it just checks to see if the random number has been assigned. If so, then it begins the game as normal, if not, it ends the game and pops back to the menu.

Greenshank answered 24/8, 2015 at 20:45 Comment(0)
D
1

You should implement the GKMatchmakerViewControllerDelegate protocol.

Deandre answered 10/6, 2015 at 7:4 Comment(0)
G
0

Unfortunately, there is not a method (that I know of, or could find with almost 3 months of looking into it) that is called when one person disconnects in matchmaking after they have begun to connect.

Therefore, the way I got around this is once the GameViewController is presented it waits one second and then calls a method to check to see if it is connected to someone else.

To do this I have it so once the game begins each player sends the other player a random number (used to determine non-related settings later on - such as who gets to go first). When it calls the method to check to see if it is connected it just checks to see if the random number has been assigned. If so, then it begins the game as normal, if not, it ends the game and pops back to the menu.

Greenshank answered 24/8, 2015 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.