Skip to content

Commit

Permalink
feat: emit connection event for a StreamConnection (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarowolfx authored Jan 9, 2025
1 parent f125792 commit 6688ea3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/managedwriter/stream_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}

Expand Down Expand Up @@ -364,6 +367,7 @@ export class StreamConnection extends EventEmitter {
);
this.close();
this.open();
this.emit('reconnect');
}

/**
Expand All @@ -375,6 +379,7 @@ export class StreamConnection extends EventEmitter {
}
this._connection.end();
this._connection.removeAllListeners();
this.emit('close');
this._connection.destroy();
this._connection = null;
}
Expand Down
2 changes: 1 addition & 1 deletion system-test/managed_writer_client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,7 @@ describe('managedwriter.WriterClient', () => {
});

let reconnectedCalled = false;
sandbox.stub(connection, 'reconnect').callsFake(() => {
connection.on('reconnect', () => {
reconnectedCalled = true;
});

Expand Down

0 comments on commit 6688ea3

Please sign in to comment.