用户之间的实时挑战/响应
我正在制作一款游戏,我希望 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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
您很可能希望使用 C2DM 进行通知,使用 XMPP 进行实际数据传输。
You most probably want to use C2DM for the notifications and XMPP for the actual data transfer.