Private
Public Access
1
0
Files
Kordophone/kordophone/Bridge/Operations/MBIMUpdatePollOperation.m

49 lines
1.1 KiB
Mathematica
Raw Normal View History

2018-11-17 01:07:55 -08:00
//
// MBIMUpdatePollOperation.m
// kordophoned
//
// Created by James Magahern on 11/16/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import "MBIMUpdatePollOperation.h"
#import "MBIMUpdateQueue.h"
@implementation MBIMUpdatePollOperation {
__strong MBIMUpdateConsumer _updateConsumer;
}
2018-11-17 01:07:55 -08:00
+ (void)load { [super load]; }
+ (NSString *)endpointName
{
return @"pollUpdates";
}
- (void)main
{
__weak __auto_type weakSelf = self;
_updateConsumer = ^(MBIMUpdateItem *nextUpdateItem) {
NSDictionary *updateDict = [nextUpdateItem dictionaryRepresentation];
2018-11-17 01:07:55 -08:00
MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:updateDict];
weakSelf.serverCompletionBlock(response);
2018-11-17 01:07:55 -08:00
};
[[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer];
}
- (void)cancel
{
[super cancel];
[[MBIMUpdateQueue sharedInstance] removeConsumer:_updateConsumer];
2018-11-17 01:07:55 -08:00
}
- (NSObject<HTTPResponse> *)cancelAndReturnTimeoutResponse
{
[self cancel];
return [[HTTPErrorResponse alloc] initWithErrorCode:205]; // 205 = nothing to report
}
2018-11-17 01:07:55 -08:00
@end