简体   繁体   English

具有RoR 3网络服务的iPhone应用程序

[英]iPhone app with a RoR 3 web service

I am in the process of building an iPhone app with a RoR 3 web service on the back end. 我正在构建一个在后端具有RoR 3 Web服务的iPhone应用程序。 The app is a fairly simple peer-to-peer game. 该应用程序是一个相当简单的点对点游戏。 I would really appreciate it if someone could share some pointers and tips on how to best divide the operations between the web service and locally on the iPhone. 如果有人可以分享一些有关如何最好地在Web服务和iPhone本地之间划分操作的提示和技巧,我将不胜感激。

For example, chess or backgammon, is the current state of the game being constantly saved and retrieved from the server? 例如,象棋或西洋双陆棋,游戏的当前状态是否一直在保存并从服务器中检索? or is it stored locally on the iPhones of the players? 还是将其存储在播放器的iPhone本地?

Thanks! 谢谢!

This will vary wildly depending on how you want to program the application and what your needs are. 根据您要如何对应用程序进行编程以及您的需求,这将千差万别。 You could constantly save and retrieve game state from the server, you could synchronize game state at certain intervals determined by game play, or you could run mostly local. 您可以不断地从服务器保存和检索游戏状态,可以按游戏时间确定的特定时间间隔同步游戏状态,或者您可以大部分在本地运行。 It all depends on your requirements. 这完全取决于您的要求。 In general cell networks should be considered slow and unreliable (even though this isn't always true). 通常,应将小区网络视为缓慢且不可靠的(即使并非总是如此)。 Keeping data transfer to the minimum required to accomplish your goals makes your app feel more responsive and users happier (especially those in poor coverage areas and those who do not have unlimited data plans). 将数据传输保持在达到目标所需的最低限度,这将使您的应用程序响应速度更快,用户更加满意(尤其是覆盖范围较差的用户和没有无限数据计划的用户)。

That depends on whether it's a game against another player or against a computer opponent. 这取决于是与其他玩家对抗还是与计算机对手对抗。 If it's against another player, then the state would be updated on and retrieved from the server. 如果是与其他玩家对战,则状态将在服务器上更新并从服务器中检索。 If it's against a built-in AI, there would be no reason to send that state to the server, unless your AI is inside your webservice instead of including it in the actual application. 如果它是针对内置AI的,则没有理由将该状态发送到服务器,除非AI位于Web服务内部,而不是将其包含在实际应用程序中。 It's really a design decision based on what you're trying to accomplish. 这实际上是一个基于您要完成的工作的设计决策。 Generally I would recommend keeping as much as possible local to the app, unless there's a reason to do it on the server, but if there's any competitive aspect to your game, you definitely want to keep control of any calculations on your server. 通常,除非有理由在服务器上进行安装,否则我通常建议尽可能在应用程序本地进行,但是,如果您的游戏存在任何竞争方面的内容,则您绝对希望控制服务器上的所有计算。 Keep in mind that someone can always try to decompile your application or call your webservices directly passing in false data. 请记住,有人总是可以尝试反编译您的应用程序或调用您的Web服务直接传递虚假数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM