Reputation: 12636
I consider use GAE as server to communicate Android phone with thin client. My typical use scenario is: User opens web page (GAE) and request some info from remote device Device gets message, and sends it back to user through web page.
Sending messages to phone is piece of cake thanks to GCM. Hard part is return response to user. The only one idea I have is inserting response to datastore, then it query repetitively, But there are some disadvantages: delay in the communication and excessive usage of the datastore and it's quotas.
I have heard and read about channels API, but when I when using GAE there is strong possibility, that both clients will connect to different machines. Have you any ideas how to do this the right way?
To make my question more clear: Let's simplify problem. I have one servlet taking message from android client. Message is addressed to user logged in with GWT and another servlet and having it's own session instance. Have you any idea how to pass message from one servlet to other? As far as I know, there is no possibly to have it done by some automatic sendMessage() method. I just need to implement some kind of mailbox. At this moment I see memcache in this role. Perfect for it should be some service like amazon sms, but having my app dispatched between many servers makes me a bit unhappy. Queues are other idea, but not those from GAE. I don't want solutions labeled as experimental in production environment.
Upvotes: 0
Views: 408
Reputation: 2097
try Channel API is good and reliable, we are using in one of the our app MobiTexter and so far havn't faced even a single problem.
Upvotes: 1
Reputation: 15143
Channel API is your answer. Every browser instance should open a channel, which is identified by a token. It's up to you to keep track of all the tokens, probably in some sort of session data. Then you can send messages to the appropriate browser.
So far I've noticed sometimes messages fail to send. Not often, but sometimes. If the contents of your message aren't vital, it might be ok. In my case, I built a backup polling HTTP query. The benefit of the channel is that the backup polling doesn't need to be super frequent for me.
Upvotes: 2