diff --git a/lib/agent.js b/lib/agent.js index 320d7c473d8..636e72c65b2 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -54,22 +54,20 @@ class Agent extends DispatcherBase { this[kFactory] = factory this[kClients] = new Map() - const agent = this - this[kOnDrain] = (origin, targets) => { - agent.emit('drain', origin, [agent, ...targets]) + this.emit('drain', origin, [this, ...targets]) } this[kOnConnect] = (origin, targets) => { - agent.emit('connect', origin, [agent, ...targets]) + this.emit('connect', origin, [this, ...targets]) } this[kOnDisconnect] = (origin, targets, err) => { - agent.emit('disconnect', origin, [agent, ...targets], err) + this.emit('disconnect', origin, [this, ...targets], err) } this[kOnConnectionError] = (origin, targets, err) => { - agent.emit('connectionError', origin, [agent, ...targets], err) + this.emit('connectionError', origin, [this, ...targets], err) } }