jrief / django-websocket-redis

Websockets for Django applications using Redis as message queue
http://django-websocket-redis.awesto.com/
MIT License
894 stars 221 forks source link

Mobile Client Question #231

Open daesu opened 7 years ago

daesu commented 7 years ago

Hello, first thank you for this great library. I just came across it.

I have successfully ran the demo project on my local box and am now trying to change it to suit my requirements, which basically are;

A Django REST api which communicates with mobile clients via an Authorization token in the Header via various endpoints.

What I am trying to do now is to implement a chat interface between any 2 users as the following;

  1. User POST's a message to an endpoint with request data like so; {"user":"John","message":"Hello World"}

Inside the View I am sending the message like so;

redis_publisher = RedisPublisher(facility='foobar', users=[user_obj])
message = RedisMessage(message)
redis_publisher.publish_message(message)

Now this works in combination with the demo project (a logged in user will receive this).

The problem is on my mobile client end. I want to open a websocket on the client to subscribe to messages for that particular user when user auth is all happening via REST.

Is there something I can do similar to ws://127.0.0.1:8000/ws/foobar?subscribe-user- ?

Thanks in advance.