diff --git a/modules/lobbies/actors/lobby_manager.ts b/modules/lobbies/actors/lobby_manager.ts index f4aaed1d..9b21a911 100644 --- a/modules/lobbies/actors/lobby_manager.ts +++ b/modules/lobbies/actors/lobby_manager.ts @@ -27,6 +27,7 @@ import { LobbyBackendServerPortResponse } from "../utils/lobby/backend/server.ts import { regionsForBackend } from "../utils/region.ts"; import * as State from "../utils/lobby_manager/state/mod.ts"; import * as Rpc from "../utils/lobby_manager/rpc.ts"; +import { assertExists } from "jsr:@std/assert"; const MANAGER_SERVER_TAG = "manager"; const MANAGER_SERVER_TAG_VALUE = "opengb/lobbies"; @@ -413,11 +414,13 @@ export class Actor extends ActorBase { } private buildLobbyResponse( - _ctx: ActorContext, + ctx: ActorContext, lobbyId: string, ): LobbyResponse { const lobby = this.getLobby(lobbyId); + const lobbyConfig = getLobbyConfig(ctx.config, lobby.tags); + // Build backend let backend: LobbyBackendResponse; if ("test" in lobby.backend) { backend = { test: {} }; @@ -462,10 +465,16 @@ export class Actor extends ActorBase { throw new UnreachableError(lobby.backend); } + // Get region + const allRegions = regionsForBackend(lobbyConfig.backend); + const region = allRegions.find(x => x.slug == lobby.region); + assertExists(region, "could not find region for lobby"); + return { id: lobby.id, version: lobby.version, tags: lobby.tags, + region, createdAt: lobby.createdAt, readyAt: lobby.readyAt, players: Object.keys(lobby.players).length, diff --git a/modules/lobbies/utils/lobby/mod.ts b/modules/lobbies/utils/lobby/mod.ts index 243b22b3..b186b7d4 100644 --- a/modules/lobbies/utils/lobby/mod.ts +++ b/modules/lobbies/utils/lobby/mod.ts @@ -3,6 +3,7 @@ import { LobbyBackendServerResponse } from "./backend/server.ts"; import { LobbyBackendLocalDevelopmentResponse, } from "./backend/local_development.ts"; +import { Region } from "../region.ts"; /** * Check if a lobby with the given tags matches a query. @@ -21,6 +22,7 @@ export interface LobbyResponse { id: string; version: string; tags: Record; + region: Region, createdAt: number; readyAt?: number; diff --git a/sandbox/sdk/package.json b/sandbox/sdk/package.json index fd7d0d7e..4cd34fa6 100644 --- a/sandbox/sdk/package.json +++ b/sandbox/sdk/package.json @@ -1,37 +1,37 @@ { - "name": "rivet-sdk", - "version": "1.0.0", - "repository": { - "type": "git", - "url": "https://github.com/rivet-gg/rivet.git" - }, - "scripts": { - "build": "tsup", - "prepare": "npm run build" - }, + "name": "rivet-sdk", + "version": "1.0.0", + "repository": { + "type": "git", + "url": "https://github.com/rivet-gg/rivet.git" + }, + "scripts": { + "build": "tsup", + "prepare": "npm run build" + }, - "devDependencies": { - "typescript": "^4.0 || ^5.0", - "tsup": "^8.3.0" - }, + "devDependencies": { + "typescript": "^4.0 || ^5.0", + "tsup": "^8.3.0" + }, - "tsup": { - "entry": ["src/index.ts"], - "format": ["esm", "cjs", "iife"], - "sourcemap": true, - "dts": true - }, + "tsup": { + "entry": ["src/index.ts"], + "format": ["esm", "cjs", "iife"], + "sourcemap": true, + "dts": true + }, - "files": ["dist"], - "main": "./dist/index.js", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "browser": "./dist/index.global.js", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } - } + "files": ["dist"], + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "browser": "./dist/index.global.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + } } diff --git a/sandbox/sdk/tsconfig.json b/sandbox/sdk/tsconfig.json index 22c32655..0490d9c1 100644 --- a/sandbox/sdk/tsconfig.json +++ b/sandbox/sdk/tsconfig.json @@ -1,14 +1,13 @@ { - "compilerOptions": { - "declaration": true, - "target": "esnext", - "module": "commonjs", - "moduleResolution": "node", - "allowImportingTsExtensions": true - }, - "exclude": [ - "dist", - "node_modules" - ] + "compilerOptions": { + "declaration": true, + "target": "esnext", + "module": "commonjs", + "moduleResolution": "node", + "allowImportingTsExtensions": true + }, + "exclude": [ + "dist", + "node_modules" + ] } -