使 iPhone 应用程序与 GWT 应用程序保持同步

发布于 2024-08-22 02:56:42 字数 413 浏览 9 评论 0原文

我正在开发一款 iPhone 应用程序,它应该可以在离线和在线模式下运行。
在在线模式下,它应该将用户输入的所有信息提供给由 GWT/GAE 支持的 Web 服务。 在离线模式下,它应该在本地存储信息,当连接可用时将其同步到网络服务。

目前我的计划如下:

  1. 使用 Protobuffers 在应用程序和 Web 服务之间提供连接,以实现高效的无线通信
  2. 使用 Core Data 与本地数据库一起工作
  3. 轮询网络状态,并在可用时同步数据库并保留某种本地状态-db-to-remote-db 密钥同步。

问题是——我的方向正确吗?是实现这个的标准模式吗?也许有人可以向我指出一个以类似方式工作的开源应用程序?

我对 iPhone 编码非常陌生,很高兴听到任何建议。

谢谢

I'm working on an iPhone application that should work in offline and online modes.
In it's online mode it's supposed to feed all the information the user enters to a webservice backed by GWT/GAE.
In it's offline mode it's supposed to store the information locally, and when connection is available sync it up to the web service.

Currently my plan is as follows:

  1. Provide a connection between an app and a webservice using Protobuffers for efficient over-the-wire communication
  2. Work with local DB using Core Data
  3. Poll the network status, and when available sync the database and keep some sort of local-db-to-remote-db key synchronization.

The question is - am I in the right direction? Are the standard patterns for implementing this? Maybe someone can point me to an open-source application that works in a similar fashion?

I am really new to iPhone coding, and would be very glad to hear any suggestions.

Thanks

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

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

发布评论

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

评论(3

家住魔仙堡 2024-08-29 02:56:42

我认为你把这些问题混淆在一起了。

  • 如果您对制作 GWT Web 界面有疑问,那就是一个问题。
  • 有关如何将 iPhone 同步到网络服务的问题是另一个问题。为此,您不想使用 GWT 的 RPC 进行同步,因为您必须在 iPhone 代码中伪造序列化系统的“浏览器端”,而 GWT 通常会为您提供该系统。

I think you've blurring the questions together.

  • If you've got a question about making a GWT web interface, that's one question.
  • Questions about how to sync an iPhone to a web service are a different question. For that, you don't want to use GWT's RPCs for syncing, as you'd have to fake out the 'browser-side' of the serialization system in your iPhone code, which GWT normally provides for you.
素手挽清风 2024-08-29 02:56:42

关于系统设计方向:
首先,如果没有真正的需要,请不要创建 2 个不同的应用程序,一个是 GWT,另一个是 iPhone
创建一个编写良好的 GWT 应用程序。它将离线工作,没有问题,并将使用 HTML 功能 -- 离线应用程序缓存
如果必须创建 2 个独立的应用程序
至少可以节省自己的精力,并且不要编写服务器两次,就像使用标准 GWT 方法一样,您几乎肯定无法从独立应用程序与服务器通信(它是通过 HTTP 压缩的 JSON,带有一些棘手的标头...)或者将两次编写内容,因此请查看 RestLet 库,它受到 GAE 的良好支持。

关于离线/在线切换保持同步的方式:
有多种方法需要考虑,但它们都不是完美的。因此,当您考虑您的想法时,请考虑您的用户的期望...不要成为 Microsoft Word,不要试图智胜用户。
如果用例中至少有一个场景需要用户干预来合并更改(并且将会有 - 将其带到银行) - 那么您将为此实现 UI - 那么就有充分的理由经常使用它 -用户会习惯的。自从他开始使用该应用程序以来,它比在一段时间内看到它要好,因为很少有需要,因为您实现了一个超级骗子合并逻辑,仅在非常特殊的情况下询问用户......不要这样做。
平衡努力。因为此类代码中的错误会给用户带来的混乱比带来的好处要痛苦得多。

那么如何:
一种方法是“Do-UnDo”方法。
离线时 - 按照用户执行操作的时间顺序保留用户对数据执行的操作日志
一旦连接 - 发送到服务器并执行它们。从服务器到客户端都是一样的。
只要您编写的不是每次操作都包含大量数据的 Photoshop 类软件,大多数情况下都可以正常工作。 GangOfFour 也将其称为“动作模式”。

另一种方法是源代码控制方法。 - 版本甚至可能是锁。非常依赖于应用程序。 DBMS 内部有时使用它来实现事务。

并且总有一个选项是离线时只读:-)

about system design direction:
First if there is no REAL need do not create 2 different apps one GWT and other iPhone
create one but well written GWT app. It will work off line no problem and will manage your data using HTML feature -- offline application cache
If it a must to create 2 separate apps
than at least save yourself effort and do not write server twice as if you go with standard GWT aproach you will almost sertanly fail to talk to server from stand alone app (it is zipped JSON over HTTP with some tricky headers...) or will write things twise so look in to the RestLet library it well supported by the GAE.

About the way to keep sync with offline / online switching:
There are several aproaches to consider and all of them are not perfect. So when you conseder yours think of what youser expects... Do not be Microsoft Word do not try to outsmart the user.
If there at least one scenario in the use cases that demand user intervention to merge changes (And there will be - take it to the bank) - than you will have implement UI for this - than there is a good reason to use it often - user will get used to it. it better than it will see it in a while since he started to use the app because a need fro it is rare because you implemented a super duper merging logic that asks user only in very special cases... Don't do it.
balance the effort. Because the mess that a bug in such code will introduce to user is much more painful than the benefit all together.

so the HOW:
The one way is the Do-UnDo way.
While off line - keep the log of actions user did on data in timed order user did them
as soon as you connected - send to server and execute them. Same from server to client.
Will work fine in most cases as long as you are not writing a Photoshop kind of software with huge amounts of data per operation. Also referred as Action Pattern by the GangOfFour.

Another way is a source control way. - Versions and may be even locks. very application dependent. DBMS internally some times use it for transactions implementations.

And there is always an option to be Read Only when Ofline :-)

清浅ˋ旧时光 2024-08-29 02:56:42

想知道您是否考虑过使用同步框架来管理同步。如果您对此感兴趣,可以查看开源项目 OpenMobster 的同步服务。您可以执行以下同步操作:

  • 双向、
  • 单向客户端、
  • 单向设备
  • 启动

除此之外,所有修改都会自动跟踪并与云端同步。当网络连接断开时,您可以让应用程序离线。它将跟踪任何更改,并在连接恢复时自动在后台将其与云同步。它还提供像 iCloud 一样跨多个设备的同步功能

。此外,云中的修改是使用推送通知进行同步的,因此即使数据存储在本地,数据也始终是最新的。

以下是开源项目的链接:http://openmobster.googlecode.com

这里是 iPhone 的链接应用程序同步:http://code.google.com/p/openmobster/wiki/iPhoneSyncApp< /a>

Wonder if you have considered using a Sync Framework to manage the synchronization. If that interests you can take a look at the open source project, OpenMobster's Sync service. You can do the following sync operations

  • two-way
  • one-way client
  • one-way device
  • bootup

Besides that, all modifications are automatically tracked and synced with the Cloud. You can have your app offline when network connection is down. It will track any changes and automatically in the background synchronize it with the cloud when the connection returns. It also provides synchronization like iCloud across multiple devices

Also, modifications in the Cloud are synched using Push notifications, so the data is always current even if it is stored locally.

Here is a link to the open source project: http://openmobster.googlecode.com

Here is a link to iPhone App Sync: http://code.google.com/p/openmobster/wiki/iPhoneSyncApp

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