MTXClient: Add support for logging out

FossilOrigin-Name: c29845b7b81229ea7bf062304824a4087c160629216064ae1a647fe8286826bb
This commit is contained in:
Jonathan Schleifer 2020-10-03 16:21:34 +00:00
parent 023ed62f5a
commit 77a2d20fc7
11 changed files with 209 additions and 25 deletions

View file

@ -35,6 +35,13 @@ OF_ASSUME_NONNULL_BEGIN
typedef void (^mtx_client_login_block_t)(MTXClient *_Nullable client,
id _Nullable exception);
/**
* @brief A block called when the device was logged out.
*
* @param exception `nil` on success, otherwise an exception
*/
typedef void (^mtx_client_logout_block_t)(id _Nullable exception);
/**
* @brief A class that represents a client.
*/
@ -92,6 +99,15 @@ typedef void (^mtx_client_login_block_t)(MTXClient *_Nullable client,
deviceID: (OFString *)deviceID
accessToken: (OFString *)accessToken
homeserver: (OFURL *)homeserver OF_DESIGNATED_INITIALIZER;
/**
* @brief Logs out the device and invalidates the access token.
*
* @warning The client can no longer be used after this succeeded!
*
* @param block The block to call when logging out succeeded or failed
*/
- (void)asyncLogOutWithBlock: (mtx_client_logout_block_t)block;
@end
OF_ASSUME_NONNULL_END