Browse Source

Implement disconnect method for external processes (Fixes #684)

pull/789/head
Miguel Grinberg 4 years ago
parent
commit
a830c9f788
  1. 4
      src/socketio/pubsub_manager.py
  2. 6
      tests/common/test_pubsub_manager.py

4
src/socketio/pubsub_manager.py

@ -75,6 +75,10 @@ class PubSubManager(BaseManager):
self._publish({'method': 'disconnect', 'sid': sid,
'namespace': namespace or '/'})
def disconnect(self, sid, namespace=None):
self._publish({'method': 'disconnect', 'sid': sid,
'namespace': namespace or '/'})
def close_room(self, room, namespace=None):
self._publish({'method': 'close_room', 'room': room,
'namespace': namespace or '/'})

6
tests/common/test_pubsub_manager.py

@ -169,6 +169,12 @@ class TestPubSubManager(unittest.TestCase):
{'method': 'disconnect', 'sid': sid, 'namespace': '/foo'}
)
def test_disconnect(self):
self.pm.disconnect('foo')
self.pm._publish.assert_called_once_with(
{'method': 'disconnect', 'sid': 'foo', 'namespace': '/'}
)
def test_close_room(self):
self.pm.close_room('foo')
self.pm._publish.assert_called_once_with(

Loading…
Cancel
Save