mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-18 16:34:27 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user