objective-c - GameKit 与 GKMatchSendDataReliable 的通信是否可靠?

标签 objective-c ios game-center gamekit

我正在使用 GameKit.framework 并尝试在两部 iPhone 之间创建可靠通信。

我正在使用 GKMatchSendDataReliable 模式发送包。

文档说:

GKMatchSendDataReliable

The data is sent continuously until it is successfully received by the intended recipients or the connection times out. Reliable transmissions are delivered in the order they were sent. Use this when you need to guarantee delivery.

Available in iOS 4.1 and later. Declared in GKMatch.h.

我在 WiFi 连接不佳时遇到了一些问题。 GameKit 不会声明连接丢失,但有些包永远不会到达。

在使用 GKMatchSendDataReliable 时,我可以指望 100% 可靠的通信吗?还是 Apple 只是为他们没有实现的东西使用了奇特的名称?

最佳答案

我的用户还提示在游戏过程中可能会意外丢失一些数据。我写了一个test app并发现 GKMatchSendDataReliable 并不可靠。在弱互联网连接(例如 EDGE)上,一些数据包经常丢失,而 Game Center API 没有任何错误。

因此唯一的选择是添加一个额外的传输层以实现真正可靠的传输。

我为此编写了一个简单的库:RoUTP .它保存所有发送的消息,直到对每个接收到的消息进行确认,重新发送丢失的消息并在序列中断的情况下缓冲接收到的消息。 在我的测试组合中,“RoUTP + GKMatchSendDataUnreliable”的效果甚至比“RoUTP + GKMatchSendDataReliable”更好(当然也比纯 GKMatchSendDataReliable 好,后者并不可靠)。

关于objective-c - GameKit 与 GKMatchSendDataReliable 的通信是否可靠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12090060/

相关文章:

ios - 具有多种颜色的 UIProgressView 上的 UILabel

objective-c - ARC Objective-C : How can self be deallocated?

ios - UIWebView 上的后退按钮

ios - 如何在加载数据后切换SpriteKit场景并确保GameCenter成功登录?

objective-c - 按 UIButton 导致无法识别的选择器错误

ios - 无论如何检查 CloudKit 应用程序以开发人员或生产模式运行?

苹果手机 : How to keep 3G/GPRS preferred network in presence of Wifi?

ios - 为什么没有调用 gameCenterViewControllerDidFinish?

swift - 如何在 TurnBasedGame 中定义配对过程的超时而不需要长时间等待?

c# - 从跨平台 DLL 返回整数数组