Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Oct 5, 2024
1 parent d9f50b6 commit 0894f32
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class WebSocket extends EventEmitter {
}

ping() {
if(this.readyState !== this.OPEN) return;
this.ws.ping();
}

Expand All @@ -66,6 +67,10 @@ class WebSocket extends EventEmitter {
}

send(data, options = {}, callback) {
if(this.readyState !== this.OPEN) {
if(callback) callback(new Error("WebSocket is not open"));
return;
}
if(typeof options === "function") {
callback = options;
options = {};
Expand Down

0 comments on commit 0894f32

Please sign in to comment.