Skip to content

Commit

Permalink
fix: a bug where socket getting disconnect won't kill socket
Browse files Browse the repository at this point in the history
  • Loading branch information
xhayper committed Dec 25, 2022
1 parent 553f919 commit 0c254bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xhayper/discord-rpc",
"version": "1.0.14",
"version": "1.0.15",
"description": "a fork of discordjs/RPC",
"main": "dist/index.js",
"author": "xhayper",
Expand Down
1 change: 1 addition & 0 deletions src/transport/IPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class IPCTransport extends Transport {
});

this.socket.on("close", () => {
this.socket = undefined;
this.emit("close", "Closed by Discord");
});
}
Expand Down
1 change: 1 addition & 0 deletions src/transport/WebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class WebSocketTransport extends Transport {

this.ws!.onclose = (event) => {
if (!event.wasClean) return;
this.ws = undefined;
this.emit("close", event.reason);
};

Expand Down

0 comments on commit 0c254bf

Please sign in to comment.