@@ -28,10 +28,14 @@ @end OF_APPLICATION_DELEGATE(Tests) @implementation Tests +{ + MTXClient *_client; +} + - (void)applicationDidFinishLaunching { __auto_type environment = OFApplication.environment; if (environment[@"OBJMATRIX_USER"] == nil || environment[@"OBJMATRIX_PASS"] == nil || @@ -50,20 +54,41 @@ if (exception != nil) { of_log(@"Error logging in: %@", exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Logged in client: %@", client); - - [client asyncLogOutWithBlock: ^ (id exception) { - if (exception != nil) { - of_log(@"Failed to log out: %@\n", exception); - [OFApplication terminateWithStatus: 1]; - } - - of_log(@"Logged out client"); - - [OFApplication terminate]; - }]; + _client = [client retain]; + of_log(@"Logged in client: %@", _client); + + [self fetchRoomList]; + }]; +} + +- (void)fetchRoomList +{ + [_client asyncFetchRoomList: ^ (OFArray *rooms, + id exception) { + if (exception != nil) { + of_log(@"Failed to fetch room list: %@", exception); + [OFApplication terminateWithStatus: 1]; + } + + of_log(@"Fetched room list: %@", rooms); + + [self logOut]; + }]; +} + +- (void)logOut +{ + [_client asyncLogOutWithBlock: ^ (id exception) { + if (exception != nil) { + of_log(@"Failed to log out: %@\n", exception); + [OFApplication terminateWithStatus: 1]; + } + + of_log(@"Logged out client"); + + [OFApplication terminate]; }]; } @end