diff --git a/README.rst b/README.rst index cc052e3..83ea1e7 100644 --- a/README.rst +++ b/README.rst @@ -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. diff --git a/socketio/base_manager.py b/socketio/base_manager.py index 58d4faa..24cd288 100644 --- a/socketio/base_manager.py +++ b/socketio/base_manager.py @@ -62,6 +62,10 @@ class BaseManager(object): 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) diff --git a/tests/common/test_base_manager.py b/tests/common/test_base_manager.py index 9518a46..af949ce 100644 --- a/tests/common/test_base_manager.py +++ b/tests/common/test_base_manager.py @@ -28,6 +28,11 @@ class TestBaseManager(unittest.TestCase): 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')