Client Communication over GAE - java

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:
I want an Android app to send a message to GAE.
This message should be retreived by my PC App(C#/Java client)
PC App should return a response to this message
PC response should send to Mobile App.
Actually I am trying to execute commands on the windows command prompt from my mobile.

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

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.

Related

Send http response to application from server using captured packets

I am trying to simulate a response from a web server login confirmation to a windows application. I have the captured packets that detail the conversation between the server and the application for successful login already as it is my application, this is for debugging and MIME simulation to test application and network security. communications create what I hope can be a custom foolproof way to prevent a MIME but I dont have a way to test it, so here I am to ask for guidance.
How would I go about simulating the response from the server to the application?
I have some idea in the direction I would possibly need to go to achieve my desired outcome:
Utilizing my network:
I have a Linux machine set up as a dynamic router, dhcp, routing, and my Linksys router just acts as an access point and ethernet switch.
1: Set up web server on Linux machine.
2: redirect traffic from application port to Linux server.
3: run server-side script to respond to application request using packets captured to establish replay successful login to server.
So, I am kinda new to using Linux tools. I have setup a Linux router, captured basic information utilizing Wireshark, and am able to program in VB, javascript, some java. I have not done much network-oriented programming other than some simple communication for authentication I have successfully established.
Any information to point me in the right direction I am grateful for!
Most logins use encryption (https / TLS) so capturing the packets won't help.
If not, the packets will form a http request, and you should be able to see the format of the request, whether the login credentials are part of the URL for GET or part of the http body for POST. It is not hard to create your own http request.
How are parameters sent in an HTTP POST request?
Each http request will be followed by an http response from the server, and the format of the headers or body will contain the login result (http requests and responses are similar in format, but the headers are not the same).
More sophisticated logins may involve a series of requests/responses.
You will need to write a simpler server to receive the requests and send the responses. Java is probably your best choice, given the languages you know, plus there will be plenty of examples online. With JS it may be possible but for the most part JS is used in browsers, so not a great choice. VB is a Windows language not supported on Linux.

How to make apprtc demo sample video chat to be fast in native android

I have done some research on webrtc then i found apprtc demo sample application which is have taken from https://github.com/njovy/AppRTCDemo in android. I have implemented this but this app take time in offering a call.It follow these step
1) It first request to webrtc server and then a json return from server.
2) In program it collect 4 ice url by hitting the turn server url and save it in linkedlist.
3) Then it send offer by appending roomid , clientid and message in webrtc server url which return success.
4) it open it socket for communication in future.
5) Now it hit the server four time with ice server which return candidate in
json formate.
6)Now I have taken our own server which send call to other person mobile.
7) Then other person accept the request and make a post on webrtc server url
and json return from it.
8) Now the answer is created and hit the socket to open.
9) The Icecandidate is accepted by the person and send that icecandidate to other person.
The webrtc server which i have taken is Google App Engine written in python. In this i don't know how to notify other person to pick call. Here I have used other server to notify other person for call.
After following these steps the communication start. Is there any way to make this step less so that communication can become fast.
Also I have taken my own server to make a call to other person. I don't know python that's why it difficult for me to edit the server so that it will help in communication without taking help of other server.

how to secure android app and webserver communication

My android app uses GCM to send or receive text messages. At first, when a user install my app, it uses the GCM api to get a GCM_id from Google. After getting this long GCM id, app sends this id to my web server to say that this client is registered with that id.
My question is that about this step. Since firstly app gets the GCM id and sends it to my web server, I think, someone can listen the requests of the app and sends dummy GCM_ids for this client (or any other clients if guess my client id format). How can I secure this step to prevent unwanted interrupts and attacks.
While creating gcm_id, if google would send this id to my server also before sending it to client, it would be a solution to my problem. But google sends it to client only directly.
ps: Using ssl is not a solution I think. Because it can also be opened by programs like fiddler .

Google Cloud Messaging and MySQL database

I want to use Google Cloud Messaging for my app for both upstream and downstream use, using xmpp. However I am wondering how I can select and input data to and from my MySQL database to be sent over the GCM network.
Can I use PHP with GCM or do I have to use Java or Python?
GCM is used for sending messages FROM server TO your android application. Also a GCM message can only carry a maximum of 4KB Only.
So in my opinion, send data to your MySQL db directly from the app (If you want to make this asynchronous, look into Android Sync Adapter); and for sending data from server to your application asynchronously, send a ping to your app using GCM (it can be any short message), so your app can undergo a normal http request-response procedure to get the data from MySQL.
For more information of Sync Adapters: http://developer.android.com/training/sync-adapters/index.html
And for a tutorial on a simple GCM using PHP: http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html
There are XMPP libraries for PHP. See https://code.google.com/p/xmpphp/ for example.
So, PHP is possible, however i would really like to hear what is a recommended approach, as im going to implement it too.

How do I send data to an android app from Google App Engine?

As I understand it, there are two ways to send data from GAE to my app:
The app does a request and the server sends the data as a response.
The server sends the data directly to the app without the app doing a request.
I know how to send data with (1) but how do I send data with (2)?
It seems you are looking for Google Cloud messaging which helps "Push"ing the messages from your server to your app (via GCM Service)
Read for details
http://developer.android.com/guide/google/gcm/index.html

Categories

Resources