diff --git a/lib/remote-server.js b/lib/remote-server.js index b8797b6..dd16ee6 100644 --- a/lib/remote-server.js +++ b/lib/remote-server.js @@ -125,7 +125,20 @@ class RemoteServer { }); ws.on('error', () => { + clearTimeout(authTimeout); + const client = this._clients.get(ws); + const wasAuthenticated = client && client.authenticated; this._clients.delete(ws); + + if (wasAuthenticated) { + this._config.onSignalingToCapture({ + type: 'client-disconnected', + clientId: client.id + }); + if (this.getClientCount() === 0) { + this._config.onDestroyCaptureWindow(); + } + } }); }