Skip to content

Commit 8e9b8fa

Browse files
authored
feat: Add a logout function for disposal of the client (#163)
* feat: Add a logout function for disposal of the client Signed-off-by: Jacob Schlecht <dadadah@echoha.us> * fix: typo Signed-off-by: Jacob Schlecht <dadadah@echoha.us> --------- Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
1 parent cfc2b5b commit 8e9b8fa

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Client.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,18 @@ export class Client extends AsyncEventEmitter<Events> {
395395
this.connect();
396396
}
397397

398+
/**
399+
* Log out of current session
400+
*
401+
* This function prepares the client for disposal by removing all event listeners and killing the events socket.
402+
*/
403+
async logout(): Promise<void> {
404+
await this.api.post("/auth/session/logout");
405+
this.events.removeAllListeners();
406+
this.removeAllListeners();
407+
this.events.disconnect();
408+
}
409+
398410
/**
399411
* Prepare a markdown-based message to be displayed to the user as plain text.
400412
* @param source Source markdown text

0 commit comments

Comments
 (0)