Private
Public Access
1
0
Files
Kordophone/kordophone/Bridge/Operations/MBIMUpdatePollOperation.m
2018-11-17 01:07:55 -08:00

40 lines
970 B
Objective-C

//
// MBIMUpdatePollOperation.m
// kordophoned
//
// Created by James Magahern on 11/16/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import "MBIMUpdatePollOperation.h"
#import "MBIMUpdateQueue.h"
#import "IMMessageItem+Encoded.h"
@implementation MBIMUpdatePollOperation
+ (void)load { [super load]; }
+ (NSString *)endpointName
{
return @"pollUpdates";
}
- (void)main
{
MBIMUpdateConsumer consumer = ^(MBIMUpdateItem *nextUpdateItem) {
NSDictionary *updateDict = @{
@"guid" : [[nextUpdateItem changedChat] guid],
@"message" : [[nextUpdateItem message] mbim_dictionaryRepresentation]
};
MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:updateDict];
self.serverCompletionBlock(response);
};
[[MBIMUpdateQueue sharedInstance] addConsumer:consumer];
}
// TODO: cancel needs to remove the consumer from the update queue
@end