Supports polling for updates
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user