Skip to content

Commit 267653f

Browse files
committed
🎨 add websocket support for node.js environment
1 parent 591f753 commit 267653f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎src/plugins/gather.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Game } from "@gathertown/gather-game-client";
22
import dixt, { DixtPlugin, Log, merge } from "dixt";
33
import * as cron from "node-cron";
4+
import WebSocket from "ws";
45

56
const name = "dixt-plugin-gather";
67

@@ -68,6 +69,11 @@ const dixtPluginGather: DixtPlugin<DixtPluginGatherOptions> = (
6869
}
6970

7071
client.once("ready", () => {
72+
// Set WebSocket globally for Node.js environment
73+
if (typeof global !== "undefined" && !global.WebSocket) {
74+
global.WebSocket = WebSocket as any;
75+
}
76+
7177
const formattedSpaceId = spaceId.replace(/\//g, "\\");
7278
game = new Game(formattedSpaceId, () => Promise.resolve({ apiKey }));
7379

0 commit comments

Comments
 (0)