Batch updates, and fixing bug where daemon would crash when accessing IMCore stuff from different threads
This commit is contained in:
@@ -22,15 +22,25 @@
|
||||
|
||||
- (void)main
|
||||
{
|
||||
NSInteger messageSeq = -1;
|
||||
NSString *messageSeqString = [self valueForQueryItemWithName:@"seq"];
|
||||
if (messageSeqString) {
|
||||
messageSeq = [messageSeqString integerValue];
|
||||
}
|
||||
|
||||
__weak __auto_type weakSelf = self;
|
||||
_updateConsumer = ^(MBIMUpdateItem *nextUpdateItem) {
|
||||
NSDictionary *updateDict = [nextUpdateItem dictionaryRepresentation];
|
||||
_updateConsumer = ^(NSArray<MBIMUpdateItem *> *updates) {
|
||||
NSMutableArray *encodedUpdates = [NSMutableArray array];
|
||||
for (MBIMUpdateItem *item in updates) {
|
||||
NSDictionary *updateDict = [item dictionaryRepresentation];
|
||||
[encodedUpdates addObject:updateDict];
|
||||
}
|
||||
|
||||
MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:updateDict];
|
||||
MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:encodedUpdates];
|
||||
weakSelf.serverCompletionBlock(response);
|
||||
};
|
||||
|
||||
[[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer];
|
||||
[[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer withLastSyncedMessageSeq:messageSeq];
|
||||
}
|
||||
|
||||
- (void)cancel
|
||||
|
||||
Reference in New Issue
Block a user