Skip to content

Commit

Permalink
feat: logout disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
akastercomcom committed Sep 20, 2023
1 parent 1feb377 commit 2b39280
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ainize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export default class Ainize {
console.log('login success! address:', this.ain.getAddress());
}

logout() {
async logout() {
await this.handler.disconnect();
this.ain.removeDefaultAccount();
console.log('logout success!');
}

async getAddress(): Promise<string> {
Expand Down
6 changes: 6 additions & 0 deletions src/handlers/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export default class Handler {
await this.ain.getEventManager().connect({},this.disconnectedCb);
console.log('connected');
};

async disconnect() {
this.checkEventManager();
await this.ain.getEventManager().disconnect();
console.log('disconnected');
}

private async disconnectedCb() {
console.log('disconnected. reconnecting...');
Expand Down

0 comments on commit 2b39280

Please sign in to comment.