通过 3G/WWAN 进行游戏中心多人游戏 - getLocalConnectionData 超时
我有一个使用 GameCenter 进行联网的多人游戏。使用 GKMatch 通过 wifi 进行网络游戏可以完美运行,但通过 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。典型的输出是一个 UIAlertView
,显示第一个dispatch_async 块中的行“操作无法完成。getLocalConnectionData
超时”。如果我使用 NSLog
输出错误代码,则为 503。
如果您已经让 GameCenter
多人游戏在 3G 上运行并且不想仔细研究我的代码,请感受一下免费分享您的工作代码,我会尽力找出我的代码出了问题!谢谢!
I have a multiplayer game that uses GameCenter for networking. Network games over wifi using GKMatch work perfectly, but over 3G they never connect. My
-[GKMatchmaker findMatchForRequest:
withCompletionHandler:]
completion handler block is invoked with an error code 503, which isn't a GKErrorDomainCode
according to that header. Instead it appears to be an HTTP error code.
Here's my code:
//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
just logs the player into GameCenter. Typical output from this would be a UIAlertView
saying "The operation could not be completed. getLocalConnectionData
timed out" from the line in the first dispatch_async block. If I use NSLog
to output the error code, it's 503.
If you've gotten GameCenter
multiplayer to work over 3G and don't want to pore over my code, feel free to share your working code and I'll try to find where mine goes wrong! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论