Private
Public Access
1
0

Supports polling for updates

This commit is contained in:
James Magahern
2018-11-17 01:07:55 -08:00
parent 464e9fe22c
commit ddec4be8d6
12 changed files with 316 additions and 11 deletions

View File

@@ -8,7 +8,9 @@
#import "MBIMBridge.h"
#import "MBIMBridgeOperation.h"
#import "MBIMConcurrentHTTPServer.h"
#import "MBIMHTTPConnection.h"
#import "MBIMUpdateQueue.h"
#import "hooking.h"
#import <CocoaHTTPServer/HTTPServer.h>
@@ -22,7 +24,7 @@
static NSString *const MBIMBridgeToken = @"net.buzzert.kordophone";
@interface MBIMBridge (/* INTERNAL */)
@property (nonatomic, strong) HTTPServer *httpServer;
@property (nonatomic, strong) MBIMConcurrentHTTPServer *httpServer;
@property (nonatomic, strong) NSOperationQueue *operationQueue;
- (instancetype)_init;
@@ -52,6 +54,7 @@ static NSString *const MBIMBridgeToken = @"net.buzzert.kordophone";
[sDaemonListener addHandler:self];
_operationQueue = [[NSOperationQueue alloc] init];
_operationQueue.maxConcurrentOperationCount = 5;
}
return self;
@@ -115,7 +118,19 @@ static NSString *const MBIMBridgeToken = @"net.buzzert.kordophone";
{
NSLog(@"Received message from chat with GUID: %@", [[notification object] guid]);
// TODO: Notify observers or something
IMChat *chat = [notification object];
IMMessage *message = [[notification userInfo] objectForKey:IMChatValueKey];
if (chat && message) {
if (![message isFromMe]) {
MBIMUpdateItem *updateItem = [[MBIMUpdateItem alloc] init];
updateItem.changedChat = chat;
updateItem.message = message;
[[MBIMUpdateQueue sharedInstance] enqueueUpdateItem:updateItem];
} else {
// TODO: care about messages from me?
}
}
}
- (void)_chatRegistryDidLoad:(NSNotification *)notification
@@ -133,7 +148,7 @@ static NSString *const MBIMBridgeToken = @"net.buzzert.kordophone";
- (void)startWebServer
{
self.httpServer = [[HTTPServer alloc] init];
self.httpServer = [[MBIMConcurrentHTTPServer alloc] init];
[self.httpServer setConnectionClass:[MBIMHTTPConnection class]];
[self.httpServer setPort:8080];