我有一个多人游戏,使用GameCenter进行网络连接 . 使用GKMatch的无线网络游戏可以很好地工作,但是在3G上它们从不连接 . 我的

-[GKMatchmaker findMatchForRequest:
withCompletionHandler:]

使用错误代码503调用完成处理程序块,根据该标头,错误代码503不是 GKErrorDomainCode . 相反,它似乎是一个HTTP错误代码 .

这是我的代码:

//GKLocalPlayer is already authenticated at this point
    _matchRequest = [[[GKMatchRequest alloc] init] autorelease];
    [_matchRequest setMinPlayers: 2];
    [_matchRequest setMaxPlayers: 2];
    GKMatchmaker *matchmaker = [GKMatchmaker sharedMatchmaker];
    [matchmaker findMatchForRequest: _matchRequest
              withCompletionHandler:
     ^(GKMatch *match, NSError *error) {
         if (error)
         {
             if ([error code] != GKErrorCancelled)
             {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     [[[[UIAlertView alloc] initWithTitle: 
                          NSLocalizedString(@"Can't find match.", @"Alert title for when automatching failed") 
                          message: [error localizedDescription] 
                          delegate: nil 
                          cancelButtonTitle: NSLocalizedString(@"OK", @"Button text for OK button") 
                          otherButtonTitles: nil] autorelease] show];
                 });
             }
             else
             {
                    NSLog(@"Canceled :(");
             }
         }
         else
         { 
             dispatch_async(dispatch_get_main_queue(), ^{
                 // do some main-thread stuff specific to my app
                 _match = [match retain];
                 [_match setDelegate: self];
             });
         }
     } ];
}

SNJGKLocalPlayerManager 只需将播放器记录到GameCenter中 . 这样的典型输出是 UIAlertView 说“操作无法完成. getLocalConnectionData 超时”来自第一个dispatch_async块中的行 . 如果我使用 NSLog 输出错误代码,则为503 .

如果你已经有多人通过3G工作,那就不要试图找到我的错误!谢谢!