开发 Android 在线纸牌游戏
我目前正在开发一款 Android 多人纸牌游戏,使用 Google App Engine 作为后端。 我想知道我应该使用哪种协议来与服务器通信 android 客户端,UDP 还是 TCP? 我知道它们之间的“干”差异,但我不确定在这种情况下什么适合我。 游戏将包含多个 (10+) 个房间,每个房间可容纳 4-6 名玩家。
I'm currently developing a multi player card game for android with Google App Engine as my back-end.
I'd like to know which protocol should i use to communicate android clients with the server, UDP or TCP?
I'm aware of the "dry" differences between them but i'm not sure what is appropriate for me in this case.
The game will consist several (10+) rooms which can populate 4-6 players each.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该确保 Google App Engine 支持您想要使用的所有内容。有几种方法可以解决此问题,有些选项在 GAE 上不可用。您提到您想要几个不同的游戏室,我假设您希望它是实时的。 Google App Engine 对线程和套接字服务器等内容有一些限制。这些限制可能会使此类应用程序难以以有效的方式执行(不使用“轮询”)。
有多种方法可以解决此问题,例如使用 Google 的 Channel API:http://code.google .com/appengine/docs/java/channel/
API 看起来相当不错,但它将您的托管选项限制为仅限 Google App Engine,我认为这还不错,而且您始终可以重写您的稍后应用。
You should make sure Google App Engine supports everything you'd want to use. There are a few options on ways to go about this, and some options are not available on GAE. You mention that you want several different game rooms, and I assume you want it to be real time. Google App Engine has some restrictions on things like threads and socket servers. These restrictions might make this type of application hard to do in an efficient way (without using "polling").
There are ways to get around this like using Google's Channel API: http://code.google.com/appengine/docs/java/channel/
The API looks quite good but it limits your hosting options to only Google App Engine, which isn't so bad I suppose, and you can always rewrite that part of your app later.
如果您希望它在大多数情况下都能工作,最好的方法是使用 HTTP 和 JSON。您更有可能确定您的用户流量将通过提供商代理等。
我会远距离远离 UDP。无法保证 UDP 数据包实际传送到客户端或服务器,您甚至不知道它们丢失了。 UDP 唯一合理的情况是,如果您正在开发一个每个人都在同一网络上的游戏。但随后您可能会将 TCP 全部整合在一起并使用蓝牙。
If you want it to work most of the time the best would be using HTTP with JSON. You are more likely to be certain that your users traffic would go through the provider proxies, etc.
I would stay away from UDP over long distances. There is no guarantee for UDP packets to be actually delivered to the clients or servers and you wouldn't even know that they got lost. The only rational case for UDP is if you are developing a game where everybody is on the same network. But then you might just scrape TCP all together and just go with the Bluetooth.
使用 Google App Engine,您只能使用 HTTP/HTTPS 进行通信,不允许使用 UDP/TCP 套接字通信。
With Google App Engine you can only communicate with HTTP/HTTPS, no UDP/TCP socket communication is allowed.