YH_NetworkAdapter+Live.m 3.01 KB
//
//  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