Overview
Comment: | Initial skeleton for handling sync |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4df5567c11f971e1ea5422bb00f70468 |
User & Date: | js on 2020-10-06 20:48:14 |
Other Links: | manifest | tags |
Context
2020-10-09
| ||
22:08 | MTXStorage: Add support for storing joined rooms check-in: 027eb0e2f8 user: js tags: trunk | |
2020-10-06
| ||
20:48 | Initial skeleton for handling sync check-in: 4df5567c11 user: js tags: trunk | |
2020-10-04
| ||
01:33 | MTXStorage: Add transactions check-in: 5d9f93730c user: js tags: trunk | |
Changes
Modified src/MTXClient.m from [ebe5b898bb] to [c274b7e572].
︙ | ︙ | |||
226 227 228 229 230 231 232 | OFString *nextBatch = response[@"next_batch"]; if (![nextBatch isKindOfClass: OFString.class]) { block([OFInvalidServerReplyException exception]); return; } @try { | > | | > > > > > > > > > > > | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | OFString *nextBatch = response[@"next_batch"]; if (![nextBatch isKindOfClass: OFString.class]) { block([OFInvalidServerReplyException exception]); return; } @try { [_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; } block(nil); }]; |
︙ | ︙ | |||
404 405 406 407 408 409 410 411 | } block(nil); }]; objc_autoreleasePoolPop(pool); } @end | > > > > > > > > > > > > > > > > | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | } block(nil); }]; objc_autoreleasePoolPop(pool); } - (void)processRoomsSync: (OFDictionary<OFString *, id> *)rooms { } - (void)processPresenceSync: (OFDictionary<OFString *, id> *)presence { } - (void)processAccountDataSync: (OFDictionary<OFString *, id> *)accountData { } - (void)processToDeviceSync: (OFDictionary<OFString *, id> *)toDevice { } @end |
Modified tests/tests.m from [247888a299] to [9eabf30e59].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | @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 || | > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | @end OF_APPLICATION_DELEGATE(Tests) @implementation Tests { MTXClient *_client; OFString *_roomID; } - (void)applicationDidFinishLaunching { __auto_type environment = OFApplication.environment; if (environment[@"OBJMATRIX_USER"] == nil || environment[@"OBJMATRIX_PASS"] == nil || |
︙ | ︙ | |||
102 103 104 105 106 107 108 | [_client joinRoom: room block: ^ (OFString *roomID, id exception) { if (exception != nil) { of_log(@"Failed to join room %@: %@", room, exception); [OFApplication terminateWithStatus: 1]; } | > | > > > > > > > > > > > > > > > | | | | | | | | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | [_client joinRoom: room block: ^ (OFString *roomID, id exception) { if (exception != nil) { of_log(@"Failed to join room %@: %@", room, exception); [OFApplication terminateWithStatus: 1]; } _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]; }]; } - (void)sendMessage { [_client sendMessage: @"ObjMatrix test successful!" roomID: _roomID block: ^ (id exception) { if (exception != nil) { of_log(@"Failed to send message to room %@: %@", _roomID, exception); [OFApplication terminateWithStatus: 1]; } of_log(@"Message sent to %@", _roomID); [self leaveRoom]; }]; } - (void)leaveRoom { [_client leaveRoom: _roomID block: ^ (id exception) { if (exception != nil) { of_log(@"Failed to leave room %@: %@", exception); [OFApplication terminateWithStatus: 1]; } of_log(@"Left room %@", _roomID); [self logOut]; }]; } - (void)logOut { |
︙ | ︙ |