1

ネットワークに GameCenter を使用するマルチプレイヤー ゲームがあります。GKMatch を使用した Wi-Fi 経由のネットワーク ゲームは問題なく動作しますが、3G 経由では接続できません。じぶんの

-[GKMatchmaker findMatchForRequest:
withCompletionHandler:]

完了ハンドラ ブロックがエラー コード 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 にログインさせるだけです。これからの典型的な出力は、最初のdispatch_asyncブロックの行からの「UIAlertView操作を完了できませんでした。getLocalConnectionDataタイムアウトしました」ということです。エラーコードを出力するために使用NSLogすると、503です。

GameCenterマルチプレイヤーが 3G で動作するようになり、私のコードを詳しく調べたくない場合は、動作するコードを自由に共有してください。どこが間違っているかを見つけようとします! ありがとう!

4

0 に答える 0