Skip to content

Commit

Permalink
Increase listener count
Browse files Browse the repository at this point in the history
  • Loading branch information
Linux123123 committed Nov 27, 2023
1 parent ad13293 commit 377b3d6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/client/Websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class WebsocketClient extends EventEmitter {
private getToken: () => Promise<WebsocketAuthData>
) {
super();
// Allow 100 listeners for this instance
this.setMaxListeners(100);
this.updateToken = ((
getToken: () => Promise<WebsocketAuthData>,
socket: WebsocketClient
Expand Down Expand Up @@ -71,6 +73,11 @@ export class WebsocketClient extends EventEmitter {
private connect(url: string): this {
this.url = url;

// Close socket if needed
if (this.socket?.ws.OPEN) {
this.socket.close();
}

this.socket = new Socket(this.url, {
onmessage: (e) => {
try {
Expand Down

0 comments on commit 377b3d6

Please sign in to comment.