游戏套件延迟

发布于 2024-12-21 06:47:23 字数 249 浏览 3 评论 0 原文

我在使用 GKSessions 时遇到以下问题: 有时,在客户端/服务器应用程序中发送数据时会出现巨大的延迟(3-4 秒,有时长达 10 秒)。

如果服务器在延迟期间发送了 10 个数据包,则客户端会立即收到这 10 个数据包。奇怪的是,在延迟期间服务器仍然接收来自客户端的数据包。

这种延迟在 WiFi 网络中似乎更严重,但在蓝牙网络中也会发生。

有其他人在使用 gamekit 时遇到过这样的延迟峰值吗? 这个问题的根源可能是什么?

I have the following problem with GKSessions:
Sometimes there is a huge delay when sending data (3-4 seconds sometimes up to 10 seconds) in a client/server application.

If the server sends let's say 10 packets during the delay, those 10 packets are received all at once on the client. The weird thing is that the server still receives packets from the clients during the delay.

This delay seems to be worse in WiFi networks but also happens in bluetooth networks.

Did anyone else encounter such delay spikes when using gamekit?
What could be the source of this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜点 2024-12-28 06:47:23

我在 gamekit 和 gksession 方面做了很多工作。我总是使用 Peer2Peer 模式,尽管有些人不鼓励它。我从来没有遇到过像你描述的那样的延迟。

您使用 GKSendDataReliable 还是 GKSendDataUnreliable 发送?尝试切换到另一个,看看它是否会改变任何东西。如果您使用 GKSendDataReliable,则发送设备将等待来自接收器的“已接收”消息,然后再发送下一条消息。这可能就是问题所在。

在您的测试设备上:是否正在运行任何可能导致网络泛滥的内容?

我正在测试基于多人游戏套件的游戏,如果我有多个活动设备,那么突然有些设备会完全停止,我需要硬重启(完全关闭并重新启动)它们才能使它们再次工作。

如果您不断遇到麻烦,您可能需要尝试更底层的 api: dns-sd https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/dns_discovery_api/Introduction.html

我希望你能成功,祝你好运!

I've been working a lot with gamekit and gksession. I always use the Peer2Peer mode even though some people discourage it. I never experience any kind of delay like the one you describe.

Do you send with GKSendDataReliable or GKSendDataUnreliable? Try switching to the other and see if it changes anything. If you're using GKSendDataReliable then the sending device will wait for a "Received" message from the receiver before sending the next message. This might be the problem.

On your testing devices: Is anything running which might flood the network?

I was testing a multiplayer gamekit based game, and if I had several active devices then suddenly some would stall completely, and I needed to hard reboot (shut down completely and restart) them to make them work again.

If you keep getting in trouble you might want to try a much more low level api: dns-sd https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/dns_discovery_api/Introduction.html

I hope you make it work, good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文