Adds websocket updates via the /updates endpoint
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CocoaHTTPServer/HTTPMessage.h>
|
||||
#import <CocoaHTTPServer/HTTPResponse.h>
|
||||
#import <CocoaHTTPServer/HTTPErrorResponse.h>
|
||||
|
||||
@@ -20,6 +21,7 @@ typedef void (^MBIMBridgeOperationCompletionBlock)(NSObject<HTTPResponse> * _Nul
|
||||
@property (class, nonatomic, readonly) NSString *endpointName;
|
||||
@property (class, nonatomic, readonly) BOOL requiresAuthentication; // default YES
|
||||
|
||||
@property (nonatomic, strong) HTTPMessage *request;
|
||||
@property (nonatomic, strong) NSData *requestBodyData;
|
||||
@property (nonatomic, readonly) NSURL *requestURL;
|
||||
@property (nonatomic, readonly) MBIMBridgeOperationCompletionBlock serverCompletionBlock;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
#import "MBIMURLUtilities.h"
|
||||
|
||||
@interface MBIMBridgeOperation (/*INTERNAL*/)
|
||||
@property (nonatomic, strong) NSURL *requestURL;
|
||||
@@ -79,18 +80,7 @@
|
||||
|
||||
- (NSString *)valueForQueryItemWithName:(NSString *)queryItemName
|
||||
{
|
||||
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self.requestURL
|
||||
resolvingAgainstBaseURL:NO];
|
||||
|
||||
NSString *value = nil;
|
||||
for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
|
||||
if ([[queryItem name] isEqualToString:queryItemName]) {
|
||||
value = [queryItem value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
return [[self requestURL] valueForQueryItemWithName:queryItemName];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -40,13 +40,13 @@
|
||||
weakSelf.serverCompletionBlock(response);
|
||||
};
|
||||
|
||||
[[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer withLastSyncedMessageSeq:messageSeq];
|
||||
[[MBIMUpdateQueue sharedInstance] addPollingConsumer:_updateConsumer withLastSyncedMessageSeq:messageSeq];
|
||||
}
|
||||
|
||||
- (void)cancel
|
||||
{
|
||||
[super cancel];
|
||||
[[MBIMUpdateQueue sharedInstance] removeConsumer:_updateConsumer];
|
||||
[[MBIMUpdateQueue sharedInstance] removePollingConsumer:_updateConsumer];
|
||||
}
|
||||
|
||||
- (NSObject<HTTPResponse> *)cancelAndReturnTimeoutResponse
|
||||
|
||||
17
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.h
Normal file
17
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMURLUtilities.h
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 1/17/23.
|
||||
// Copyright © 2023 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSURL (MBIMURLUtilities)
|
||||
- (nullable NSString *)valueForQueryItemWithName:(NSString *)queryItemName;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
28
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.m
Normal file
28
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.m
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// MBIMURLUtilities.m
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 1/17/23.
|
||||
// Copyright © 2023 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMURLUtilities.h"
|
||||
|
||||
@implementation NSURL (MBIMURLUtilities)
|
||||
|
||||
- (nullable NSString *)valueForQueryItemWithName:(NSString *)queryItemName
|
||||
{
|
||||
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self resolvingAgainstBaseURL:NO];
|
||||
|
||||
NSString *value = nil;
|
||||
for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
|
||||
if ([[queryItem name] isEqualToString:queryItemName]) {
|
||||
value = [queryItem value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user