Differences From Artifact [a5246fd62c]:
- File src/MTXClient.m — part of check-in [3c84d235e5] at 2020-10-03 19:47:26 on branch trunk — Add support for storage (user: js, size: 9609) [annotate] [blame] [check-ins using]
To Artifact [348fd1db0b]:
- File
src/MTXClient.m
— part of check-in
[17e299f073]
at
2020-10-03 21:56:23
on branch trunk
— Initial support for sync
Only sends the sync, does not do anything with the response yet. Handling the response will be implemented in the next several commits, piece by piece. (user: js, size: 10378) [annotate] [blame] [check-ins using]
︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | + | #import "MTXFetchRoomListFailedException.h" #import "MTXJoinRoomFailedException.h" #import "MTXLeaveRoomFailedException.h" #import "MTXLoginFailedException.h" #import "MTXLogoutFailedException.h" #import "MTXSendMessageFailedException.h" #import "MTXSyncFailedException.h" static void validateHomeserver(OFURL *homeserver) { if (![homeserver.scheme isEqual: @"http"] && ![homeserver.scheme isEqual: @"https"]) @throw [OFUnsupportedProtocolException |
︙ | |||
190 191 192 193 194 195 196 197 198 199 200 201 202 203 | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | - (MTXRequest *)requestWithPath: (OFString *)path { return [MTXRequest requestWithPath: path accessToken: _accessToken homeserver: _homeserver]; } - (void)syncWithTimeout: (of_time_interval_t)timeout block: (mtx_client_response_block_t)block { void *pool = objc_autoreleasePoolPush(); MTXRequest *request = [self requestWithPath: @"/_matrix/client/r0/sync"]; unsigned long long timeoutMs = timeout * 1000; request.query = [OFString stringWithFormat: @"timeout=%llu", timeoutMs]; [request performWithBlock: ^ (mtx_response_t response, int statusCode, id exception) { if (exception != nil) { block(exception); return; } if (statusCode != 200) { block([MTXSyncFailedException exceptionWithStatusCode: statusCode response: response client: self]); return; } block(nil); }]; objc_autoreleasePoolPop(pool); } - (void)logOutWithBlock: (mtx_client_response_block_t)block { void *pool = objc_autoreleasePoolPush(); MTXRequest *request = [self requestWithPath: @"/_matrix/client/r0/logout"]; request.method = OF_HTTP_REQUEST_METHOD_POST; |
︙ |