游戏中心需要永远显示断开连接

时间:2011-09-24 04:10:56

标签: objective-c game-center

当游戏中心运行匹配并且一个玩家断开连接时,断开连接方法至少需要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;
    }                 

}

1 个答案:

答案 0 :(得分:0)

我不确定,但我有一个建议给你......

如果你使用线程而不是强行退出线程......

并查看此链接以了解有关线程的更多信息...

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html

并检查如何终止线程。