Skip to content

Commit

Permalink
Implement disconnect method for external processes (Fixes #684)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Aug 20, 2021
1 parent 37651d9 commit a830c9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/socketio/pubsub_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def can_disconnect(self, sid, namespace):
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 '/'})
Expand Down
6 changes: 6 additions & 0 deletions tests/common/test_pubsub_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ def test_can_disconnect(self):
{'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(
Expand Down

0 comments on commit a830c9f

Please sign in to comment.