21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
+
|
*/
#import "MTXClient.h"
#import "MTXRequest.h"
#import "MTXFetchRoomListFailedException.h"
#import "MTXJoinRoomFailedException.h"
#import "MTXLeaveRoomFailedException.h"
#import "MTXLoginFailedException.h"
#import "MTXLogoutFailedException.h"
static void
validateHomeserver(OFURL *homeserver)
{
if (![homeserver.scheme isEqual: @"http"] &&
|
280
281
282
283
284
285
286
287
288
289
290
|
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if (![roomID isKindOfClass: OFString.class]) {
block(nil, [OFInvalidServerReplyException exception]);
return;
}
block(roomID, nil);
}];
objc_autoreleasePoolPop(pool);
}
- (void)leaveRoom: (OFString *)roomID
block: (mtx_client_room_leave_block_t)block
{
void *pool = objc_autoreleasePoolPush();
MTXRequest *request = [self requestWithPath: [OFString
stringWithFormat: @"/_matrix/client/r0/rooms/%@/leave", roomID]];
request.method = OF_HTTP_REQUEST_METHOD_POST;
[request performWithBlock: ^ (mtx_response_t response, int statusCode,
id exception) {
if (exception != nil) {
block(exception);
return;
}
if (statusCode != 200) {
block([MTXLeaveRoomFailedException
exceptionWithRoomID: roomID
statusCode: statusCode
response: response
client: self]);
return;
}
block(nil);
}];
objc_autoreleasePoolPop(pool);
}
@end
|