Skip to content

Commit

Permalink
Conversion from Socket.IO sid to Engine.IO sid
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Dec 8, 2020
1 parent af2e263 commit 805b33f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ is to use the same version of this package for the client and the server. If you
using this package with a different client or server, then you must ensure the
versions are compatible.

The version compatiblity chart below maps versions of this package to versions
The version compatibility chart below maps versions of this package to versions
of the JavaScript reference implementation and the versions of the Socket.IO and
Engine.IO protocols.

Expand Down
4 changes: 4 additions & 0 deletions socketio/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def sid_from_eio_sid(self, eio_sid, namespace):
if namespace in self.rooms:
return self.rooms[namespace][None].inverse.get(eio_sid)

def eio_sid_from_sid(self, sid, namespace):
if namespace in self.rooms:
return self.rooms[namespace][None].get(sid)

def can_disconnect(self, sid, namespace):
return self.is_connected(sid, namespace)

Expand Down
5 changes: 5 additions & 0 deletions tests/common/test_base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def test_connect(self):
assert dict(self.bm.rooms['/foo'][None]) == {sid: '123'}
assert dict(self.bm.rooms['/foo'][sid]) == {sid: '123'}
assert self.bm.sid_from_eio_sid('123', '/foo') == sid
assert self.bm.sid_from_eio_sid('1234', '/foo') is None
assert self.bm.sid_from_eio_sid('123', '/bar') is None
assert self.bm.eio_sid_from_sid(sid, '/foo') == '123'
assert self.bm.eio_sid_from_sid('x', '/foo') is None
assert self.bm.eio_sid_from_sid(sid, '/bar') is None

def test_pre_disconnect(self):
sid1 = self.bm.connect('123', '/foo')
Expand Down

0 comments on commit 805b33f

Please sign in to comment.