Skip to content

Commit

Permalink
adds isomorphic ws for cross platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
doomestee committed Nov 28, 2023
1 parent 87021ab commit 845349c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/connection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @module Connection */
import Message from "./message";
import MessageSerializer, { Base64Processer } from "./utilities/messageserialiser";
import WebSocket from "ws";
import type { CloseEvent, ErrorEvent } from "ws";
import WebSocket from "isomorphic-ws";
import type { CloseEvent, ErrorEvent } from "isomorphic-ws";
import PlayerIOError from "./error";

interface Endpoint {
Expand Down Expand Up @@ -71,7 +71,7 @@ export default class Connection {
let endpoint = this.endpointStrings.splice(0, 1)[0];

// attempt to create a socket connection
this.socket = new WebSocket(((this.developmentServer) ? "ws://" : "wss://") + endpoint + "/", { timeout: 4000 });
this.socket = new WebSocket(((this.developmentServer) ? "ws://" : "wss://") + endpoint + "/");
this.socket.binaryType = "arraybuffer";

// I'm using addeventlistener since it's the common thing in browser/node/bun.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"license": "MIT",
"dependencies": {
"iconv-lite": "^0.6.3",
"isomorphic-ws": "^5.0.0",
"tslib": "^2.6.2",
"ws": "^8.13.0"
},
Expand Down

0 comments on commit 845349c

Please sign in to comment.