From 2afc0c766185b13597525264fea041ca880c98e2 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Mon, 12 Oct 2020 15:11:43 +0200 Subject: [PATCH] Implement BaseClient::get_session to retrieve the login session. Closes #100. --- matrix_sdk_base/src/client.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 9ac9a6e8..6557a69b 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -1886,6 +1886,16 @@ impl BaseClient { } } + /// Get the user login session. + /// + /// If the client is currently logged in, this will return a `matrix_sdk::Session` object which + /// can later be given to `restore_login`. + /// + /// Returns a session object if the client is logged in. Otherwise returns `None`. + pub async fn get_session(&self) -> Option { + self.session.read().await.clone() + } + /// Get a map holding all the devices of an user. /// /// This will always return an empty map if the client hasn't been logged