django-websocket-redis
django-websocket-redis copied to clipboard
Close all connections to a channel
In my architecture, there is one publisher and many subscribers in a broadcast channel. I want to close all subscribers' sockets when the publisher closes its socket. how can I handle this? how can I close all sockets to a channel in server side code?
here is the code of release method in my custom subscriber class:
def release(self):
if self._subscription and self._subscription.subscribed:
self._subscription.unsubscribe()
if self._publishers:
message = RedisMessage('Bye')
self.publish_message(message)
# I want to close all sockets here
else:
self.send_viewers_count()
self._subscription.reset()
(publisher is a subscriber too, but there is only one publisher)