From f7844d4bf03e8b23dfac85af0cc98e17fc353c00 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..21eaf8e96 100644 --- a/discojs/discojs-core/src/client/event_connection.ts +++ b/discojs/discojs-core/src/client/event_connection.ts @@ -1,4 +1,4 @@ -import isomorphic from 'isomorphic-ws' +import isomorphic, { WebSocket } from 'isomorphic-ws' import { EventEmitter } from 'events' import { Peer } from './decentralized/peer' import { NodeID } from './types' @@ -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 WebSocket(url) ws.binaryType = 'arraybuffer' const emitter: EventEmitter = new EventEmitter()