YH_NetworkAdapter+Live.m
3.01 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// YH_NetworkAdapter+Live.m
// yohoLive
//
// Created by 孟顺 on 16/8/18.
// Copyright © 2016年 NewPower. All rights reserved.
//
#import "YH_NetworkAdapter+Live.h"
#import "UtilsMacros.h"
@implementation YH_NetworkAdapter (Live)
- (void)getPushListFinished:(DictionaryBlock)finishBlock {
[[YH_HttpEngine roomListEngine] get:@{} success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([responseObject[@"code"] integerValue] != 200) {
NSError *anError = [NSError errorWithDomain:@"live" code:[responseObject[@"code"] integerValue] userInfo:@{}];
BLOCK_EXEC(finishBlock, nil, anError);
}else{
BLOCK_EXEC(finishBlock, responseObject,nil);
}
DLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
BLOCK_EXEC(finishBlock, nil,error);
DLog(@"%@",error);
}];
}
- (void)setStatusWithStat:(PushStatus)status andRoomId:(NSString *)room completion:(BoolBlock)block {
NSDictionary *param = @{
@"room_id":room,
@"living_stat":@(status),
};
[[YH_HttpEngine pushStatusEngine] get:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([responseObject[@"code"] integerValue] != 200) {
NSError *anError = [NSError errorWithDomain:@"live" code:[responseObject[@"code"] integerValue] userInfo:@{}];
BLOCK_EXEC(block, NO, anError);
}else{
BLOCK_EXEC(block, YES,nil);
}
DLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
BLOCK_EXEC(block, NO,error);
DLog(@"%@",error);
}];
}
- (void)validateAnchorWithSecret:(NSString *)secret andRoomId:(NSString *)room completion:(BoolBlock)block {
NSDictionary *param = @{
@"room_id":room,
@"secret":secret,
};
[[YH_HttpEngine pushStatusEngine] get:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([responseObject[@"code"] integerValue] != 200) {
NSError *anError = [NSError errorWithDomain:@"live" code:[responseObject[@"code"] integerValue] userInfo:@{}];
BLOCK_EXEC(block, NO, anError);
}else{
BLOCK_EXEC(block, YES,nil);
}
DLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
BLOCK_EXEC(block, NO,error);
DLog(@"%@",error);
}];
}
- (void)getLiveBarrageSocketAddressWithParam:(NSDictionary *)param completion:(DictionaryBlock)finishBlock {
[[YH_HttpEngine socketAddrEngine] get:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
BLOCK_EXEC(finishBlock, responseObject,nil);
NSLog(@"%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
BLOCK_EXEC(finishBlock, nil,error);
NSLog(@"%@",error);
}];
}
@end