diff --git a/backend/endpoints/netplay.py b/backend/endpoints/netplay.py index 457030aa5..ccf7937fc 100644 --- a/backend/endpoints/netplay.py +++ b/backend/endpoints/netplay.py @@ -48,17 +48,17 @@ class RoomsResponse(TypedDict): @protected_route(router.get, "/list", [Scope.ASSETS_READ]) async def get_rooms(request: Request, game_id: str) -> Dict[str, RoomsResponse]: netplay_rooms = await netplay_handler.get_all() - open_rooms: Dict[str, RoomsResponse] = {} - for session_id, room in netplay_rooms.items(): - if not _is_room_open(room, game_id): - continue - open_rooms[session_id] = RoomsResponse( + open_rooms: Dict[str, RoomsResponse] = { + session_id: RoomsResponse( room_name=room["room_name"], current=len(room["players"]), max=room["max_players"], player_name=_get_owner_player_name(room), hasPassword=bool(room["password"]), ) + for session_id, room in netplay_rooms.items() + if _is_room_open(room, game_id) + } return open_rooms diff --git a/backend/endpoints/sockets/netplay.py b/backend/endpoints/sockets/netplay.py index c871e43c6..9e71346e1 100644 --- a/backend/endpoints/sockets/netplay.py +++ b/backend/endpoints/sockets/netplay.py @@ -120,7 +120,6 @@ async def _handle_leave(sid: str, session_id: str, player_id: str): if not current_room["players"]: await netplay_handler.delete([session_id]) - await netplay_handler.set(session_id, current_room) # Notify clients that the room is now empty await netplay_socket_handler.socket_server.emit( "users-updated", {}, room=session_id diff --git a/frontend/src/views/Player/EmulatorJS/Player.vue b/frontend/src/views/Player/EmulatorJS/Player.vue index c5819c3d5..049856ebc 100644 --- a/frontend/src/views/Player/EmulatorJS/Player.vue +++ b/frontend/src/views/Player/EmulatorJS/Player.vue @@ -397,7 +397,7 @@ window.EJS_onGameStart = async () => { window.EJS_emulator.netplayGetOpenRooms = async () => { try { const response = await fetch( - `/api/netplay/list?&game_id=${window.EJS_gameID}`, + `/api/netplay/list?game_id=${window.EJS_gameID}`, ); return await response.json(); } catch (error) {