anhtran
anhtran

Reputation: 2044

Sockjs - Send message to sockjs-tornado in Python code

I use https://github.com/mrjoes/sockjs-tornado for a Django app. I can send messages from javascript console very easy. But I want to create a signal in Django and send json string once the signal is active.

Could anyone give me a way to send a certain message in Python to sockjs-tornado socket server?

Upvotes: 6

Views: 2349

Answers (3)

Andrew Magee
Andrew Magee

Reputation: 6684

I just put this up https://github.com/amagee/sockjs-client for talking directly to a SockJS server from Python (using xhr streaming).

Upvotes: 0

cheap_grayhat
cheap_grayhat

Reputation: 420

I've wrote djazator, simple and easy to use django plugin. It uses zeromq for delivering messages from django to sockjs-tornado. Additionally, it can send messages to subset of authenticated django users.

Upvotes: 1

Joes
Joes

Reputation: 1818

There are few options how to handle it:

  1. Create simple REST API in your Tornado server and post your updates from Django using this API;
  2. Use Redis. Tornado can subscribe to the update key and Django can publish updates to this key when something happens;
  3. Use ZeroMQ (AMQP, etc) to send updates from the Django to the Tornado backend (variation of the 1 and 2).

In most of the cases, it is either first or second option. Some people prefer using 3rd option though.

Upvotes: 6

Related Questions