From 02b5c40044c4ee9740a7991c38af92bc842c32bc Mon Sep 17 00:00:00 2001 From: Massimo Candela Date: Mon, 24 Jan 2022 14:49:03 +0100 Subject: [PATCH] fixed connection:undefined in logs --- src/utils/WebSocket.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/WebSocket.js b/src/utils/WebSocket.js index dd6e4fc..892b1b1 100644 --- a/src/utils/WebSocket.js +++ b/src/utils/WebSocket.js @@ -64,11 +64,11 @@ export default class WebSocket { }; _connect = () => { - const connectionId = uuidv4(); + this.connectionId = uuidv4(); const url = brembo.build(this.host.split("?")[0], { params: { ...brembo.parse(this.host).params, - connection: connectionId + connection: this.connectionId } }); @@ -85,12 +85,12 @@ export default class WebSocket { }); this.ws.on('pong', this._pingReceived); this.ws.on('error', message => { - this._publishError(message, {connection: connectionId}); + this._publishError(message); }); this.ws.on('open', () => { this.alive = true; this.setOpenTimeout(false); - this.pubsub.publish("open", { connection: connectionId }); + this.pubsub.publish("open", { connection: this.connectionId }); }); this._startPing(); @@ -120,8 +120,8 @@ export default class WebSocket { this.connectionDelay = this.reconnectSeconds; }; - _publishError = (message, extra={}) => { - this.pubsub.publish("error", { type: "error", message, ...extra }); + _publishError = (message) => { + this.pubsub.publish("error", { type: "error", message, connection: this.connectionId }); }; setOpenTimeout = (setting) => {