@@ -30,10 +30,11 @@ OF_APPLICATION_DELEGATE(Tests) @implementation Tests { MTXClient *_client; + OFString *_roomID; } - (void)applicationDidFinishLaunching { __auto_type environment = OFApplication.environment; @@ -104,43 +105,59 @@ if (exception != nil) { of_log(@"Failed to join room %@: %@", room, exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Joined room %@", roomID); + _roomID = [roomID copy]; + of_log(@"Joined room %@", _roomID); + + [self sync2]; + }]; +} + +- (void)sync2 +{ + [_client syncWithTimeout: 5 + block: ^ (id exception) { + if (exception != nil) { + of_log(@"Failed to sync: %@", exception); + [OFApplication terminateWithStatus: 1]; + } + + of_log(@"Synced"); - [self sendMessage: roomID]; + [self sendMessage]; }]; } -- (void)sendMessage: (OFString *)roomID +- (void)sendMessage { [_client sendMessage: @"ObjMatrix test successful!" - roomID: roomID + roomID: _roomID block: ^ (id exception) { if (exception != nil) { of_log(@"Failed to send message to room %@: %@", - roomID, exception); + _roomID, exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Message sent to %@", roomID); + of_log(@"Message sent to %@", _roomID); - [self leaveRoom: roomID]; + [self leaveRoom]; }]; } -- (void)leaveRoom: (OFString *)roomID +- (void)leaveRoom { - [_client leaveRoom: roomID + [_client leaveRoom: _roomID block: ^ (id exception) { if (exception != nil) { of_log(@"Failed to leave room %@: %@", exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Left room %@", roomID); + of_log(@"Left room %@", _roomID); [self logOut]; }]; }