My last entry walked through the Android application for the C2DM PoC. This one will look closer at the server side.
The web server is written in Python and sits on top of the tornado framework. To get started you will first need to check it out from github.
Then there are two things that needs changing for the serve to run. First of, tornado is included as a git sub module. In order to get the tornado server you need to run the below commands, when in the project folder, in the terminal:
$ git submodule init
$ git submodule update
This will pull down tornado from their github repository.
Secondly you will need to change the following two lines (lines 36 and 37) of code in c2dm/c2dm_service_facade.py:
self.email = 'email@example.com'
self.password = 'password'
Replace the Google account with the account you have registered to use with C2DM and the password with the password for said account.
You should now be ready to go. To launch the server on port 8888 execute the following terminal command:
There isn't much more to it. As I have said before not all requirements for C2DM is met by this application but it will work as a prof of concept.
To continue from my previous post, Google Cloud to device messaging for Android, I will walk through how to build and install the Android application.
First of all you will have to sign up for access to the service. You can do this from Googles sign-up page.
You will then have to enter the Google account id into the Constants class where you will find a constant called named C2DM_APPLICATION_SERVER_ID.
The application is using the Maven build system, utilising the maven-android plugin. This makes it very easy to build and install as long as you have Maven installed. You will need to connect your Android 2.2 device or start the emulator, then issue the following command in your shell:
$ mvn install android:deploy
For the device side this is pretty much it. When you have set up your server you can go ahead and start the application. You will be presented with a button which you click to register for receiving messages. When you then use the server to send a message you will see this being printed to the log.
I have been trying out Cloud to Device Messaging (C2DM). It is a technology from Google that makes it possible to send small messages to an Android Devices running Froyo, the latest Android 2.2 release with the Google API's enabled. The application is a very simple prof of concept that illustrates how the technology can be used. It is however not a full implementation and it is missing some required functions.
The PoC is composed by two different sub-systems, an Android application and a web application server. The servers is written in Python and is leveraging Tornado.
The system supports the message sequences depicted in the diagrams below:
Register a device for C2DM:
Sending a message to device:
In the two coming posts I will walk through how each of the sub-systems (device application and web server) works. If you are aching to get your hands on the code you will find it on github: Android application, Web server.
You will find the device side introduction here and the server side introduction here.