@@ -80,6 +80,7 @@ public final class GKMatchManager: NSObject {
8080
8181 guard GKLocalPlayer . local. isAuthenticated,
8282 let matchmakerViewController = GKMatchmakerViewController ( invite: invite) else {
83+ GKMatchmaker . shared ( ) . cancel ( )
8384 canceled ( )
8485 return nil
8586 }
@@ -91,6 +92,7 @@ public final class GKMatchManager: NSObject {
9192 public func createMatchmaker( invite: GKInvite ) -> GKMatchmakerViewController ? {
9293 guard GKLocalPlayer . local. isAuthenticated,
9394 let matchmakerViewController = GKMatchmakerViewController ( invite: invite) else {
95+ GKMatchmaker . shared ( ) . cancel ( )
9496 return nil
9597 }
9698
@@ -105,16 +107,20 @@ public final class GKMatchManager: NSObject {
105107 self . canceled = canceled
106108 self . failed = failed
107109 self . started = started
108-
109110 guard GKLocalPlayer . local. isAuthenticated,
110111 let matchmakerViewController = GKMatchmakerViewController ( matchRequest: request) else {
112+ GKMatchmaker . shared ( ) . cancel ( )
111113 canceled ( )
112114 return nil
113115 }
114116
115117 matchmakerViewController. matchmakerDelegate = self
116118 return matchmakerViewController
117119 }
120+
121+ public func cancel( ) {
122+ GKMatchmaker . shared ( ) . cancel ( )
123+ }
118124}
119125
120126extension GKMatchManager : GKMatchmakerViewControllerDelegate {
@@ -123,7 +129,7 @@ extension GKMatchManager: GKMatchmakerViewControllerDelegate {
123129 viewController. dismiss (
124130 animated: true ,
125131 completion: {
126- os_log ( " Found match !" , log: OSLog . matchmaking, type: . info)
132+ os_log ( " Matchmaking successful !" , log: OSLog . matchmaking, type: . info)
127133 self . match. send ( Match ( gkMatch: match) )
128134 self . started ( match)
129135 viewController. remove ( )
0 commit comments