Skip to content

Commit

Permalink
Add isConnected() method for event handler channel connection
Browse files Browse the repository at this point in the history
  • Loading branch information
platfowner committed Jun 12, 2024
1 parent 431eb37 commit 6aec47b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions __tests__/event_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ describe('Event Handler', function() {
ain.em.disconnect();
});

describe('Channel connection', () => {
it('isConnected()', () => {
expect(ain.em.isConnected()).toBe(true);
});
});

describe('BLOCK_FINALIZED', () => {
it('Subscribe to BLOCK_FINALIZED', (done) => {
eventFilterId = ain.em.subscribe('BLOCK_FINALIZED', {
Expand Down
7 changes: 7 additions & 0 deletions src/event-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export default class EventManager {
this._eventChannelClient = new EventChannelClient(ain, this._eventCallbackManager);
}

/**
* Returns whether the client in connection.
*/
isConnected(): boolean {
return this._eventChannelClient.isConnected;
}

/**
* Opens a new event channel.
* @param {DisconnectionCallback} disconnectionCallback The disconnection callback function.
Expand Down

0 comments on commit 6aec47b

Please sign in to comment.