Private
Public Access
1
0

Adds websocket updates via the /updates endpoint

This commit is contained in:
James Magahern
2023-01-17 16:16:23 -08:00
parent 56ae7982c6
commit 2f5d50188b
9 changed files with 181 additions and 53 deletions

View File

@@ -12,6 +12,7 @@
#import "MBIMBridge_Private.h"
#import "MBIMBridgeOperation.h"
#import "MBIMAuthToken.h"
#import "MBIMUpdateQueue.h"
#import <Security/Security.h>
#import <CocoaHTTPServer/HTTPMessage.h>
@@ -107,6 +108,7 @@
if (operationClass != nil) {
_currentOperation = [[operationClass alloc] initWithRequestURL:url completion:completion];
_currentOperation.requestBodyData = _bodyData;
_currentOperation.request = self->request;
[[[MBIMBridge sharedInstance] operationQueue] addOperation:_currentOperation];
long status = dispatch_semaphore_wait(sema, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60.0 * NSEC_PER_SEC)));
@@ -124,6 +126,17 @@
return response;
}
- (WebSocket *)webSocketForURI:(NSString *)path
{
NSURL *url = [NSURL URLWithString:path];
NSString *endpointName = [url lastPathComponent];
if ([endpointName isEqualToString:@"updates"]) {
return [[MBIMUpdateQueue sharedInstance] vendUpdateWebSocketConsumerForRequest:request socket:asyncSocket];
}
return [super webSocketForURI:path];
}
- (BOOL)expectsRequestBodyFromMethod:(NSString *)method atPath:(NSString *)path
{
if ([method isEqualToString:@"POST"]) {