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

@@ -13,6 +13,7 @@
@implementation MBIMHTTPConnection {
NSMutableData *_bodyData;
MBIMBridgeOperation *_currentOperation;
}
- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path
@@ -37,11 +38,11 @@
NSString *endpointName = [url lastPathComponent];
Class operationClass = [MBIMBridgeOperation operationClassForEndpointName:endpointName];
if (operationClass != nil) {
MBIMBridgeOperation *operation = [[operationClass alloc] initWithRequestURL:url completion:completion];
operation.requestBodyData = _bodyData;
_currentOperation = [[operationClass alloc] initWithRequestURL:url completion:completion];
_currentOperation.requestBodyData = _bodyData;
[[[MBIMBridge sharedInstance] operationQueue] addOperation:operation];
dispatch_semaphore_wait(sema, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10.0 * NSEC_PER_SEC)));
[[[MBIMBridge sharedInstance] operationQueue] addOperation:_currentOperation];
dispatch_semaphore_wait(sema, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60.0 * NSEC_PER_SEC)));
} else {
response = [[HTTPErrorResponse alloc] initWithErrorCode:404];
}
@@ -68,4 +69,10 @@
[_bodyData appendData:postDataChunk];
}
- (void)die
{
[_currentOperation cancel];
[super die];
}
@end