We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
我使用 smartFox 套接字服务器(很久以前)和 PHP/MySQL 来处理网络上的“多人状态同步”(最近)
在我看来,对于一个可能会持续数天的游戏,数据库系统会更好。套接字服务器必须在内存中维护可能数小时或数天不使用的数据。 PHP/MySQL(或 SQL)+ JSON 可能是一个非常合适的选择。大型 PHP 站点为数千个用户提供页面,并且每个页面渲染可能执行多个查询,因此我认为扩展应该没问题。
使用数据库系统的优点是它可以与平台无关。你的 Android 游戏可以通过 PhoneGap 之类的东西在 iOS 等平台上运行。
编辑:数据库系统的缺点是推送通知可能更难安装。这超出了我的专业范围。
I've used both smartFox socket server (quite awhile ago) and PHP/MySQL to handle "multiplayer state synching" on the web (recently)
In my opinion, for a game that's going to have turns that may span days, a database system would be better. A socket server would have to maintain data in memory that may not be in use for hours or days. PHP/MySQL(or SQL) + JSON would probably be a really good fit. Large PHP sites serve pages to thousands of users and may execute multiple queries per page render so I think scaling should be fine.
The advantage of using a database system is that it can be platform agnostic. Your Android game could run on iOS et al via something like PhoneGap.
EDIT: The disadvantage of a database system is Push notification might be harder to rig up. That's out of my realm of expertise.
我会完全按照你的建议去做。它不需要是 PHP,但基本上您将拥有一个 Web 服务器(可以是 nginx、apache 等),并且它可以是您想要的任何语言。
我最喜欢的方法之一是使用 Django MVC 设置,在后端使用 Python(Python 的出色之处)并使用 HttpClient(甚至 Https)进行通信。
我使用 JSON 作为中间媒介(从 XML 开始,但改为 Json,因为它通常开销较低)。
您可能还需要设置某种类型的 PUSH 系统。使用 C2DM 或第三方 API。我主要使用一个 API,因为它是免费的并且需要使用。 C2DM 之前的版本,称为 Xtify。它被设计用作地理定位工具,但它具有 PUSH 服务(并且您不需要使用 Geo 的东西)。最好的部分是,它是免费的!
这样,您可以打开应用程序,但不会通过 POLL 循环浪费电池寿命,并且只需在其他玩家的回合立即结束时即可获取。
编辑:我刚刚查看了一下,似乎 Xtify 对每个用户每月超过 300 条消息的内容收费......所以这可能不再是 PUSH 服务的最佳选择。
I would do exactly what you suggested. It doesn't need to be PHP, but basically you will have a web server (could be nginx, apache, etc), and it can be in any language you want.
One of my favorite methods is using a Django MVC setup, using Python on the backend (for awesomeness of Python) and communicate using an HttpClient (or Https even).
I used JSON as the go between (started with XML, but changed to Json as it's lower overhead usually).
You'll probably also want some kind of a PUSH system set up. Either using C2DM, or a third party API. There's an API I used mostly because it was free & pre-C2DM, called Xtify. It's designed to be used as a geolocation tool, but it has PUSH services (and you don't need to use the Geo stuff). Best part, it's free!
That way, you can have the app open, but not wasting battery life with a POLL loop, and just get when the other player's turns end instantaneously.
EDIT: I just looked and it appears that Xtify charges for anything over 300 messages per user per month... so that's probably not the best option for PUSH services anymore.