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