Django / Python: Real-time Messaging

I use Django and Gunicorn to work with front-end iOS applications. So far, I have used simple GET, PUT, POST requests to send and receive json data from my iOS application on my Django server and vice versa.

However, this setup was solid, I would like to use real-time messaging. When I first started working, I used APNS (Apple Push Notifications Service) to deliver messages in real time to recipients. Here is an example of what I used:

If UserA messaged UserB, I would send a message to the Django server via JSON, process it in the Django view, use the pyAPNS python shell for APNS, and it will send a push notification to the UserB user (recipient) along with the payload size of 256 bytes. This worked well, but it also has a few drawbacks.

If the recipient wants to disable push notifications, they will not receive the message. When you implement basic data in your iOS application, it can be quite confusing if you cache objects.

So that leaves me with another option. Building something based on sockets that can work with Django and send the payload as JSON. Any ideas?

+6
source share
1 answer

You looked here:

https://pypi.python.org/pypi/django-socketio/

or here:

http://maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/

or here:

https://www.djangopackages.com/grids/g/websockets/

It can be done.

Also, I don't understand why real-time messaging needs to be parsed in django itself. You could just implement a server like node.js to handle this for you, with the iOS application retrieving data through various APIs. This will work if you do not need messaging data attached to other data.

+6
source

All Articles