Index: src/MTXClient.m ================================================================== --- src/MTXClient.m +++ src/MTXClient.m @@ -228,12 +228,24 @@ block([OFInvalidServerReplyException exception]); return; } @try { - [_storage setNextBatch: nextBatch - forDeviceID: _deviceID]; + [_storage transactionWithBlock: ^ { + [_storage setNextBatch: nextBatch + forDeviceID: _deviceID]; + + [self processRoomsSync: response[@"rooms"]]; + [self processPresenceSync: + response[@"presence"]]; + [self processAccountDataSync: + response[@"account_data"]]; + [self processToDeviceSync: + response[@"to_device"]]; + + return true; + }]; } @catch (id e) { block(e); return; } @@ -406,6 +418,22 @@ block(nil); }]; objc_autoreleasePoolPop(pool); } + +- (void)processRoomsSync: (OFDictionary *)rooms +{ +} + +- (void)processPresenceSync: (OFDictionary *)presence +{ +} + +- (void)processAccountDataSync: (OFDictionary *)accountData +{ +} + +- (void)processToDeviceSync: (OFDictionary *)toDevice +{ +} @end Index: tests/tests.m ================================================================== --- tests/tests.m +++ tests/tests.m @@ -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]; }]; }