jrief / django-websocket-redis

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

How to restrict users from publishing to broadcast #190

Open alx377 opened 8 years ago

alx377 commented 8 years ago

Hello!

I just can not figure it out how I can restrict users from publishing messages to broadcast channel. I send information to front ends and run javascript based on that and so no client should be able to initiate such javascript on other clients.

I am publishing redis messages like this. data = json.dumps(dict) redis_message = RedisMessage(data) RedisPublisher(facility='chat', broadcast=True).publish_message(redis_message)

And catching them in frontends like this: ws.onmessage = function(e) { if (obj.type === "chat") { do chat... }

If I could get some more elaborate example of how to use WS4REDIS_ALLOWED_CHANNELS and def get_allowed_channels(request, channels): return set(channels).intersection(['subscribe-broadcast', 'subscribe-group']) function.

Thanks!