0

I have an Android app which uses Google Cloud Endpoints to synchronize data between devices. Currently in each api call a GCM message is send to all other devices. Often a devices does not only do one api call, but multiple directly after each other. In this situation it gets extremely inefficient to send a message in each call, because then all the other devices make multiple calls to get the new data instead of just one for all.

So my idea is basically after an api call wait ~10 seconds and then send a GCM message. Whenever a new call comes in and the timer gets resetted.

My problem is I don't really know how to do this in AppEngine. My first idea was a TaskQueue with a task that is named a certain way and has a 10 second delay. In the API call I check if the task is in the queue and if yes I remove it and insert a new one. This wasn't possible because a taskname can't be used again even if the task doesn't exist anymore.

4

2 に答える 2

0

GCMメッセージを送信するタイミングをデバイスに明示的に示す方がはるかに簡単ではないでしょうか。

于 2013-03-07T01:16:27.983 に答える
0

Android アプリがエンドポイント呼び出しの違いを認識している場合、つまりどちらが「最終」呼び出しであるかを認識している場合、他のデバイスに通知するかどうかをサーバーに伝えることができます。

そうでない場合でも、サーバーで行うことについて話しているのと同様のことをクライアントで行うことができます: 最後の呼び出しが行われたことが確実になるまで (たとえば、ユーザーがデータの更新を終了するまで) 遅延し続けます。次に、通知を送信する「最終」サーバー呼び出しを実行します。最終的な呼び出しが行われる前にアプリが強制終了されることが心配な場合は、サービスでこれを行うことができます。

または、クライアントの受信コードで同じことを行うこともできます。GCM 通知を受信すると、それに対応する前に遅延する可能性があります。

いずれにせよ、クライアントでこれを処理し、サーバーのトランザクションを維持する方が本当に簡単 (かつ安価) だと思います。

于 2013-03-07T03:42:25.567 に答える