jrief / django-websocket-redis

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

Close all connections to a channel #230

Open mostafa-v opened 7 years ago

mostafa-v commented 7 years ago

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?

mostafa-v commented 7 years ago

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)