Vivek Mohan
Vivek Mohan

Reputation: 8356

Client Communication over GAE

What is the best way for the communication between an Android app(native app) & a desktop App(C#/Java Client) over GAE? One way I found was Channel API. Unfortunately I found no client side scripts other than Javascript supports Channel API. Another way was to make a static class and communicate through these static variables.

This is what I'd like to achieve:

  1. I want an Android app to send a message to GAE.
  2. This message should be retreived by my PC App(C#/Java client)
  3. PC App should return a response to this message
  4. PC response should send to Mobile App.

Actually I am trying to execute commands on the windows command prompt from my mobile.

Upvotes: 0

Views: 239

Answers (2)

Ski
Ski

Reputation: 14487

Basically this is how it works:

  • GAE handler receives messages from mobile device over http, and stores it to datastore. Here is an example of request which is done by movile device over http:

    POST http://myapp.appspot.com/messages
    Content-type: application/json
    
    {"message":"Message from mobile device","userid":"myuserid",[other data..]}
    
  • Desktop app makes repetitive requests (every 10 sec or so) to GAE over http. GAE handler will give an empty response if there are no new messages, but if message has arrived, message is loaded from datastore and served over http, so you application will receive it. Here is request example:

    GET http://myapp.appspot.com/messages?last_message_id=...
    

    Database query example:

    SELECT * FROM messages WHERE message_id > LAST_MESSAGE_ID
    

    Response example:

    Content-type: application/json
    
    [{'id':1, 'message':'Message 1 from mobile device','userid':1},
     {'id':2, 'message':'Message 2 from mobile device','userid':1}]
    

With Channel-API, it is possible to make one long request (long-polling) instead of many repetitive every 10 seconds. It is more efficient but it will be more difficult to implement if libraries does not exists.

I cannot recommend you specific libraries because I don't code in C# or Java, but all you need is a library which can make http requests, and also a library which encodes and decodes data in your chosen format. JSON data encoding is used in my example.

Upvotes: 0

Rohan
Rohan

Reputation: 7976

How about:

Android <-> App Engine : C2DM

Here's a good video about it:

http://www.youtube.com/watch?v=M7SxNNC429U

C#/Java <-> App Engine : Http Post/Get, create a http servlet at the app engine side. And standard http request on c#/java.

Here's a blog about the servlet side:

http://zawoad.blogspot.com/2010/04/how-to-call-servlet-in-gwt.html

Upvotes: 1

Related Questions