diff --git a/src/api/ws.ts b/src/api/ws.ts index 3d815da..96e508e 100644 --- a/src/api/ws.ts +++ b/src/api/ws.ts @@ -38,7 +38,7 @@ export class wsClient { let msgStr = msg.toString(); debug("WebSocket", "reveived:", msgStr); let json = JSON.parse(msgStr) as { act: string, id: number, data: any }; - if (closed) { + if (!this.open) { socket.send(JSON.stringify({ id: json.id, state: "error", @@ -131,6 +131,7 @@ export class wsClient { }); socket.on('close', () => { + this.open = false; var i = clients.indexOf(this); delete clients[i]; if (i >= 0) {