1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

fixed connection:undefined in logs

This commit is contained in:
Massimo Candela
2022-01-24 14:49:03 +01:00
parent f8aa5e7bc1
commit 02b5c40044

View File

@@ -64,11 +64,11 @@ export default class WebSocket {
}; };
_connect = () => { _connect = () => {
const connectionId = uuidv4(); this.connectionId = uuidv4();
const url = brembo.build(this.host.split("?")[0], { const url = brembo.build(this.host.split("?")[0], {
params: { params: {
...brembo.parse(this.host).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('pong', this._pingReceived);
this.ws.on('error', message => { this.ws.on('error', message => {
this._publishError(message, {connection: connectionId}); this._publishError(message);
}); });
this.ws.on('open', () => { this.ws.on('open', () => {
this.alive = true; this.alive = true;
this.setOpenTimeout(false); this.setOpenTimeout(false);
this.pubsub.publish("open", { connection: connectionId }); this.pubsub.publish("open", { connection: this.connectionId });
}); });
this._startPing(); this._startPing();
@@ -120,8 +120,8 @@ export default class WebSocket {
this.connectionDelay = this.reconnectSeconds; this.connectionDelay = this.reconnectSeconds;
}; };
_publishError = (message, extra={}) => { _publishError = (message) => {
this.pubsub.publish("error", { type: "error", message, ...extra }); this.pubsub.publish("error", { type: "error", message, connection: this.connectionId });
}; };
setOpenTimeout = (setting) => { setOpenTimeout = (setting) => {