From ab4e94918aeb905813549b7d6b53b8318106b905 Mon Sep 17 00:00:00 2001 From: Chris Watts Date: Mon, 25 Nov 2024 15:31:16 +0000 Subject: [PATCH] feat: emit stream events in stream_connection.ts * feat: emit stream events in stream_connection.ts (#529) --- src/managedwriter/stream_connection.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/managedwriter/stream_connection.ts b/src/managedwriter/stream_connection.ts index da312f27..6d0e5de0 100644 --- a/src/managedwriter/stream_connection.ts +++ b/src/managedwriter/stream_connection.ts @@ -107,12 +107,15 @@ export class StreamConnection extends EventEmitter { }); this._connection.on('pause', () => { this.trace('connection paused'); + this.emit('pause'); }); this._connection.on('resume', () => { this.trace('connection resumed'); + this.emit('resume'); }); this._connection.on('end', () => { this.trace('connection ended'); + this.emit('end'); }); } @@ -364,6 +367,7 @@ export class StreamConnection extends EventEmitter { ); this.close(); this.open(); + this.emit('reconnect'); } /** @@ -375,6 +379,7 @@ export class StreamConnection extends EventEmitter { } this._connection.end(); this._connection.removeAllListeners(); + this.emit('close'); this._connection.destroy(); this._connection = null; }