开发者

Keeping iPhone application in sync with GWT application

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 Proto开发者_JAVA技巧buffers 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


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.


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 :-)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜