diff --git a/src/socketio/asyncio_manager.py b/src/socketio/asyncio_manager.py index 20a16c8..47013dc 100644 --- a/src/socketio/asyncio_manager.py +++ b/src/socketio/asyncio_manager.py @@ -15,7 +15,7 @@ class AsyncManager(BaseManager): Note: this method is a coroutine. """ - if namespace not in self.rooms or room not in self.rooms[namespace]: + if namespace not in self.rooms: return tasks = [] if not isinstance(skip_sid, list): diff --git a/tests/asyncio/test_asyncio_manager.py b/tests/asyncio/test_asyncio_manager.py index 32836bf..9d9c849 100644 --- a/tests/asyncio/test_asyncio_manager.py +++ b/tests/asyncio/test_asyncio_manager.py @@ -244,6 +244,29 @@ class TestAsyncManager(unittest.TestCase): '456', 'my event', {'foo': 'bar'}, '/foo', None ) + def test_emit_to_rooms(self): + sid1 = self.bm.connect('123', '/foo') + self.bm.enter_room(sid1, '/foo', 'bar') + sid2 = self.bm.connect('456', '/foo') + self.bm.enter_room(sid2, '/foo', 'bar') + self.bm.enter_room(sid2, '/foo', 'baz') + sid3 = self.bm.connect('789', '/foo') + self.bm.enter_room(sid3, '/foo', 'baz') + _run( + self.bm.emit('my event', {'foo': 'bar'}, namespace='/foo', + room=['bar', 'baz']) + ) + assert self.bm.server._emit_internal.mock.call_count == 3 + self.bm.server._emit_internal.mock.assert_any_call( + '123', 'my event', {'foo': 'bar'}, '/foo', None + ) + self.bm.server._emit_internal.mock.assert_any_call( + '456', 'my event', {'foo': 'bar'}, '/foo', None + ) + self.bm.server._emit_internal.mock.assert_any_call( + '789', 'my event', {'foo': 'bar'}, '/foo', None + ) + def test_emit_to_all(self): sid1 = self.bm.connect('123', '/foo') self.bm.enter_room(sid1, '/foo', 'bar')