django-websocket-redis icon indicating copy to clipboard operation
django-websocket-redis copied to clipboard

Close all connections to a channel

Open mostafa-v opened this issue 8 years ago • 1 comments

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 avatar Apr 24 '17 11:04 mostafa-v

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)

mostafa-v avatar Apr 24 '17 11:04 mostafa-v