当游戏中心运行匹配并且一个玩家断开连接时,断开连接方法至少需要30秒才能被调用。关于如何在对手退出应用程序时立即调用disconnect方法的任何想法。
(void)match:(GKMatch *)theMatch player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state {
if (match != theMatch) return;
switch (state) {
case GKPlayerStateConnected:
// handle a new player connection.
NSLog(@"Player connected!");
if (!matchStarted && theMatch.expectedPlayerCount == 0) {
NSLog(@"Ready to start match!");
[self lookupPlayers];
}
break;
case GKPlayerStateDisconnected:
// a player just disconnected.
NSLog(@"Player disconnected!");
matchStarted = NO;
[delegate matchEnded];
break;
}
}
答案 0 :(得分:0)
我不确定,但我有一个建议给你......
如果你使用线程而不是强行退出线程......
并查看此链接以了解有关线程的更多信息...
并检查如何终止线程。