// // 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; } + (void)load { [super load]; } + (NSString *)endpointName { return @"pollUpdates"; } - (void)main { __weak __auto_type weakSelf = self; _updateConsumer = ^(MBIMUpdateItem *nextUpdateItem) { NSDictionary *updateDict = [nextUpdateItem dictionaryRepresentation]; MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:updateDict]; weakSelf.serverCompletionBlock(response); }; [[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer]; } - (void)cancel { [super cancel]; [[MBIMUpdateQueue sharedInstance] removeConsumer:_updateConsumer]; } - (NSObject *)cancelAndReturnTimeoutResponse { [self cancel]; return [[HTTPErrorResponse alloc] initWithErrorCode:205]; // 205 = nothing to report } @end