Repository navigation
Expand file tree
/
Copy pathPBExampleClient.m
More file actions
46 lines (40 loc) · 1.68 KB
/
Copy pathPBExampleClient.m
File metadata and controls
46 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// PBExampleClient.m
// Pbind
//
// Created by Galen Lin on 16/9/7.
// Copyright © 2016年 galenlin. All rights reserved.
//
#import "PBExampleClient.h"
@implementation PBExampleClient
@pbclient(@"im")
- (void)loadRequest:(PBRequest *)request success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
NSString *action = request.action;
// NSString *group = request.params[@"group"];
if ([action isEqualToString:@"GetGroupInfo"]) {
id data = @{@"groupName": @"My Group",
@"memberNum": @12,
@"notification": @"Some notification",
@"faceURL:": @"https://placehold.it/165/78b8fc/f0f0f0/?text=PB"};
success(data);
} else if ([action isEqualToString:@"GetGroupMembers"]) {
NSMutableArray *members = [NSMutableArray arrayWithCapacity:12];
for (int i = 0; i < 12; i++) {
NSDictionary *member = @{@"nameCard": [NSString stringWithFormat:@"Hello%i", i + 1],
@"customInfo": @{
@"avatar": [NSString stringWithFormat:@"https://placehold.it/165/78b8fc/f0f0f0/?text=%i", i + 1]
}};
[members addObject:member];
}
id data = @{@"list": [members subarrayWithRange:NSMakeRange(0, 8)],
@"fullList": members,
@"nickname": @"My nickname"};
success(data);
} else if ([action isEqualToString:@"QuitGroup"]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
success(nil);
});
}
}
@end