From 7f7eb3bc566af62b0ec8ab042390eb435cbe1b0c Mon Sep 17 00:00:00 2001 From: tharvik Date: Thu, 8 Feb 2024 11:13:22 +0100 Subject: [PATCH] discojs-core: use isomorphic.WebSocket --- discojs/discojs-core/src/client/event_connection.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/discojs/discojs-core/src/client/event_connection.ts b/discojs/discojs-core/src/client/event_connection.ts index e32f705e4..56d622453 100644 --- a/discojs/discojs-core/src/client/event_connection.ts +++ b/discojs/discojs-core/src/client/event_connection.ts @@ -94,7 +94,7 @@ export class PeerConnection implements EventConnection { export class WebSocketServer implements EventConnection { private constructor ( - private readonly socket: WebSocket, + private readonly socket: isomorphic.WebSocket, private readonly eventEmitter: EventEmitter, private readonly validateReceived?: (msg: any) => boolean, private readonly validateSent?: (msg: any) => boolean @@ -103,8 +103,7 @@ export class WebSocketServer implements EventConnection { static async connect (url: URL, validateReceived?: (msg: any) => boolean, validateSent?: (msg: any) => boolean): Promise { - const WS = typeof window !== 'undefined' ? window.WebSocket : isomorphic.WebSocket - const ws: WebSocket = new WS(url) + const ws = new isomorphic.WebSocket(url) ws.binaryType = 'arraybuffer' const emitter: EventEmitter = new EventEmitter()