Skip to content

Commit

Permalink
Merge pull request #190 from ainblockchain/feature/platfowner/feature
Browse files Browse the repository at this point in the history
Add isConnected() method for event handler channel connection
  • Loading branch information
platfowner authored Jun 12, 2024
2 parents 431eb37 + 6aec47b commit 8df7558
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 8df7558

Please sign in to comment.