Skip to content

Commit

Permalink
adapt to new python socketio syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Nov 30, 2022
1 parent 49d190f commit 26a3b7a
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,12 @@ async def connect_to_socketio(client, user, socketio_client_factory: Callable):
"user_id": str(user["id"]),
"client_session_id": cur_client_session_id,
}
assert await socket_registry.find_keys(("socket_id", sio.sid)) == [resource_key]
assert sio.sid in await socket_registry.find_resources(resource_key, "socket_id")
assert await socket_registry.find_keys(("socket_id", sio.get_sid())) == [
resource_key
]
assert sio.get_sid() in await socket_registry.find_resources(
resource_key, "socket_id"
)
assert len(await socket_registry.find_resources(resource_key, "socket_id")) == 1
sio_connection_data = sio, resource_key
return sio_connection_data
Expand All @@ -289,12 +293,12 @@ async def connect_to_socketio(client, user, socketio_client_factory: Callable):
async def disconnect_user_from_socketio(client, sio_connection_data):
"""disconnect a previously connected socket.io connection"""
sio, resource_key = sio_connection_data
sid = sio.sid
sid = sio.get_sid()
socket_registry = get_registry(client.server.app)
await sio.disconnect()
assert not sio.sid
await asyncio.sleep(0) # just to ensure there is a context switch
assert not await socket_registry.find_keys(("socket_id", sio.sid))
assert not await socket_registry.find_keys(("socket_id", sio.get_sid()))
assert not sid in await socket_registry.find_resources(resource_key, "socket_id")
assert not await socket_registry.find_resources(resource_key, "socket_id")

Expand Down

0 comments on commit 26a3b7a

Please sign in to comment.