Skip to content

Commit

Permalink
Add support for appending room ID to URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Jan 3, 2025
1 parent ab5d41f commit 56b7368
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/ts/RoomLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import { SkipPerformedHandler } from "./spectator/handlers/SkipPerformedHandler"
let socket: Socket<SpectatorClientEvents> | null = null;
let disconnectTimeout: NodeJS.Timeout | undefined;

export function askRoomID(messagePrefix?: string): void {
export function askRoomID(
messagePrefix?: string,
existingId?: string | null,
): void {
const message =
(messagePrefix ? `${messagePrefix}\n\n` : "") +
"Enter the ID of the multiplayer room that you want to spectate.";

let roomId: string | null = null;
let roomId = existingId ?? null;
while (!roomId) {
roomId = prompt(message);
}
Expand Down
4 changes: 3 additions & 1 deletion src/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ import { openDatabase } from "./settings/DatabaseSettings";

await openDatabase();

askRoomID();
const searchParams = new URLSearchParams(location.search);

askRoomID(undefined, searchParams.get("id"));
})().catch(console.error);

0 comments on commit 56b7368

Please sign in to comment.