用户之间的实时挑战/响应

发布于 2024-12-04 09:01:35 字数 257 浏览 0 评论 0原文

我正在制作一款游戏,我希望 2 位玩家在他们的 2 个角色之间进行实时战斗。

这是所需的流程:

  • 用户在他的朋友列表中选择一个朋友,然后单击“与他战斗”
  • 选择的朋友收到通知(即使应用程序在后台)
  • 选择的朋友接受挑战
  • 两个玩家都

按照我想要的方式 战斗是通过使用位于后台(服务)的永久 TCP 连接。我担心这意味着电池电量耗尽。是否有任何 API/库旨在解决我正在解决的问题?

I'm building a game where I'd like 2 players to fight live between their 2 character.

Here is the desired flow :

  • User picks a friend in his friends list and click "fight him"
  • Picked friend receives a notification ( even if the app is in the background )
  • Picked friend accept the challenge
  • Both players fight

The way I want to do it is by using a permanent TCP connection sitting in the background ( service ). I'm afraid of the battery drain it implies. Is there any API/library designed to solve the problem I'm tackling ?

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

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

发布评论

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

评论(2

李白 2024-12-11 09:01:35

XMPP 以有限的电池消耗和有限的数据消耗来完成此类任务。 http://code.google.com/p/asmack/ 是一个很好的连接库到 XMPP 服务器

XMPP does that kind of thing with limited battery drain and limited data consumption. http://code.google.com/p/asmack/ is a good library for connecting to an XMPP server

平安喜乐 2024-12-11 09:01:35

您很可能希望使用 C2DM 进行通知,使用 XMPP 进行实际数据传输。

You most probably want to use C2DM for the notifications and XMPP for the actual data transfer.

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