Updates to sending and message sequences
This commit is contained in:
@@ -8,9 +8,10 @@
|
||||
|
||||
#import "MBIMUpdatePollOperation.h"
|
||||
#import "MBIMUpdateQueue.h"
|
||||
#import "IMMessageItem+Encoded.h"
|
||||
|
||||
@implementation MBIMUpdatePollOperation
|
||||
@implementation MBIMUpdatePollOperation {
|
||||
__strong MBIMUpdateConsumer _updateConsumer;
|
||||
}
|
||||
|
||||
+ (void)load { [super load]; }
|
||||
|
||||
@@ -21,19 +22,27 @@
|
||||
|
||||
- (void)main
|
||||
{
|
||||
MBIMUpdateConsumer consumer = ^(MBIMUpdateItem *nextUpdateItem) {
|
||||
NSDictionary *updateDict = @{
|
||||
@"guid" : [[nextUpdateItem changedChat] guid],
|
||||
@"message" : [[nextUpdateItem message] mbim_dictionaryRepresentation]
|
||||
};
|
||||
__weak __auto_type weakSelf = self;
|
||||
_updateConsumer = ^(MBIMUpdateItem *nextUpdateItem) {
|
||||
NSDictionary *updateDict = [nextUpdateItem dictionaryRepresentation];
|
||||
|
||||
MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:updateDict];
|
||||
self.serverCompletionBlock(response);
|
||||
weakSelf.serverCompletionBlock(response);
|
||||
};
|
||||
|
||||
[[MBIMUpdateQueue sharedInstance] addConsumer:consumer];
|
||||
[[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer];
|
||||
}
|
||||
|
||||
// TODO: cancel needs to remove the consumer from the update queue
|
||||
- (void)cancel
|
||||
{
|
||||
[super cancel];
|
||||
[[MBIMUpdateQueue sharedInstance] removeConsumer:_updateConsumer];
|
||||
}
|
||||
|
||||
- (NSObject<HTTPResponse> *)cancelAndReturnTimeoutResponse
|
||||
{
|
||||
[self cancel];
|
||||
return [[HTTPErrorResponse alloc] initWithErrorCode:205]; // 205 = nothing to report
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user