Android : Referring a currently open XMPP connection from another python script present inside a django server

on Friday, August 22, 2014


My application server's requirements are as follows:



  1. Receive sensor data from mobile phones (using HTTP)

  2. Process them (python libraries)

  3. Send notification to the mobile devices (rendered as notifications on Android devices)


Implementation Setup:


In order to do the above, my server has three modules:



  • Django app module: Provides an HTTP interface to the inference library to cater to the HTTP requests sent by the Android devices to the server.

  • Python Inference Library: Processes the sensor data received from the phones

  • GCM App Server Module: explained below


GCM App Server Module: I have implemented GCM Message App Server using CCS that talks to the Google's servers (that sits between the app server and Android devices) for delivering messages to/from mobile devices running Android. Following is from their official website (previous link):



The GCM Cloud Connection Server (CCS) is an XMPP endpoint that provides a persistent, asynchronous, bidirectional connection to Google servers. The connection can be used to send and receive messages between your server and your users' GCM-connected devices.



In the documentation, they have given a sample python script that I have referred and used to implement my GCM App server. This implementation is executed as a standalone script.


Python Inference Library and Django app module: I have implemented the inference library in python that processes sensor data received from the phones. It has a Django interface to talk to the Android devices. The inference library resides inside the Django app server.


PROBLEM:


The GCM App Server script contains a few functions, one of them being send_message(), that sends messages to the Android devices. I need to refer this function in my inference library scripts when some processed data is available to be sent to the devices. Or I need to refer to the persistent open XMPP connection (that runs forever) client to send messages. I want to avoid putting the processing code in the GCM app server script. I have been stuck for weeks to find a way to do the above.


Is there a way to do this with my current setup or do I need to add some other layer/module?


Any help or suggestions would be greatly appreciated.


Thanks.


0 comments:

Post a Comment