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()