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>
This commit is contained in:
Jacob Schlecht
2026-05-23 13:17:45 -06:00
committed by GitHub
parent cfc2b5b433
commit 8e9b8fa71a
+12
View File
@@ -395,6 +395,18 @@ export class Client extends AsyncEventEmitter<Events> {
this.connect();
}
/**
* Log out of current session
*
* This function prepares the client for disposal by removing all event listeners and killing the events socket.
*/
async logout(): Promise<void> {
await this.api.post("/auth/session/logout");
this.events.removeAllListeners();
this.removeAllListeners();
this.events.disconnect();
}
/**
* Prepare a markdown-based message to be displayed to the user as plain text.
* @param source Source markdown text