-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method for creating wrapper SDK proxy client
TODO same for REST?
- Loading branch information
1 parent
72d7c98
commit 146c2dc
Showing
14 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#import "ARTRealtimeWrapperSDKProxy.h" | ||
#import "ARTRealtimeWrapperSDKProxy+Private.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface ARTRealtimeWrapperSDKProxy () | ||
|
||
@property (nonatomic, readonly) ARTRealtime *realtime; | ||
@property (nonatomic, readonly) ARTWrapperProxyOptions *options; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
@implementation ARTRealtimeWrapperSDKProxy | ||
|
||
- (instancetype)initWithRealtime:(ARTRealtime *)realtime | ||
options:(ARTWrapperProxyOptions *)options { | ||
if (self = [super init]) { | ||
_realtime = realtime; | ||
_options = options; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (ARTConnection *)connection { | ||
return self.realtime.connection; | ||
} | ||
|
||
- (ARTRealtimeChannels *)channels { | ||
return self.realtime.channels; | ||
} | ||
|
||
- (ARTPush *)push { | ||
return self.realtime.push; | ||
} | ||
|
||
- (ARTAuth *)auth { | ||
return self.realtime.auth; | ||
} | ||
|
||
- (NSString *)clientId { | ||
return self.realtime.clientId; | ||
} | ||
|
||
#if TARGET_OS_IOS | ||
- (ARTLocalDevice *)device { | ||
return self.realtime.device; | ||
} | ||
#endif | ||
|
||
- (void)close { | ||
[self.realtime close]; | ||
} | ||
|
||
- (void)connect { | ||
[self.realtime connect]; | ||
} | ||
|
||
- (nonnull id<ARTRealtimeProtocol>)createWrapperSDKProxyWithOptions:(nonnull ARTWrapperProxyOptions *)options { | ||
@throw [NSException exceptionWithName:NSInvalidArgumentException | ||
reason:@"You can not call -createWrapperProxyWithOptions: on a proxy object." | ||
userInfo: nil]; | ||
} | ||
|
||
- (void)ping:(nonnull ARTCallback)cb { | ||
[self.realtime ping:cb]; | ||
} | ||
|
||
- (BOOL)request:(nonnull NSString *)method | ||
path:(nonnull NSString *)path | ||
params:(nullable NSStringDictionary *)params | ||
body:(nullable id)body | ||
headers:(nullable NSStringDictionary *)headers | ||
callback:(nonnull ARTHTTPPaginatedCallback)callback | ||
error:(NSError * _Nullable __autoreleasing * _Nullable)errorPtr { | ||
return [self.realtime request:method | ||
path:path | ||
params:params | ||
body:body | ||
headers:headers | ||
callback:callback | ||
error:errorPtr]; | ||
} | ||
|
||
- (BOOL)stats:(nonnull ARTPaginatedStatsCallback)callback { | ||
return [self.realtime stats:callback]; | ||
} | ||
|
||
- (BOOL)stats:(nullable ARTStatsQuery *)query callback:(nonnull ARTPaginatedStatsCallback)callback error:(NSError * _Nullable __autoreleasing * _Nullable)errorPtr { | ||
return [self.realtime stats:query | ||
callback:callback | ||
error:errorPtr]; | ||
} | ||
|
||
- (void)time:(nonnull ARTDateTimeCallback)callback { | ||
[self.realtime time:callback]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import "ARTWrapperProxyOptions.h" | ||
|
||
@implementation ARTWrapperProxyOptions | ||
|
||
- (instancetype)initWithAgent:(NSString *)agent { | ||
if (self = [super init]) { | ||
_agent = [agent copy];; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Source/PrivateHeaders/Ably/ARTRealtimeWrapperSDKProxy+Private.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import <Ably/ARTRealtimeWrapperSDKProxy.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface ARTRealtimeWrapperSDKProxy () | ||
|
||
- (instancetype)initWithRealtime:(ARTRealtime *)realtime | ||
options:(ARTWrapperProxyOptions *)options NS_DESIGNATED_INITIALIZER; | ||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <Ably/ARTRealtime.h> | ||
|
||
@class ARTWrapperProxyOptions; | ||
@class ARTConnection; | ||
@class ARTRealtimeChannels; | ||
@class ARTPush; | ||
@class ARTAuth; | ||
|
||
// TODO exclude from docs | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
NS_SWIFT_SENDABLE | ||
@interface ARTRealtimeWrapperSDKProxy : NSObject <ARTRealtimeProtocol> | ||
|
||
@property (readonly) ARTConnection *connection; | ||
@property (readonly) ARTRealtimeChannels *channels; | ||
@property (readonly) ARTPush *push; | ||
@property (readonly) ARTAuth *auth; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
NS_SWIFT_SENDABLE | ||
@interface ARTWrapperProxyOptions: NSObject | ||
|
||
@property (nonatomic, readonly) NSString *agent; | ||
|
||
- (instancetype)initWithAgent:(NSString *)agent NS_DESIGNATED_INITIALIZER; | ||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import XCTest | ||
|
||
class WrapperSDKProxyTests { | ||
func testRealtimeAPI() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import XCTest | ||
|
||
class WrapperSDKProxyTests { | ||
func testRealtimeAPI() throws { | ||
let test = Test() | ||
let options = try AblyTests.commonAppSetup(for: test) | ||
let client = AblyTests.newRealtime(options).client | ||
defer { client.dispose(); client.close() } | ||
|
||
let proxyClient = client.createWrapperSDKProxy(with: .init(agent: test.id.uuidString)) | ||
|
||
// TODO get these compiling, then start adding other APIs here | ||
|
||
let _ = proxyClient.connection | ||
// | ||
let channel = proxyClient.channels.get(test.uniqueChannelName()) | ||
|
||
channel.attach() | ||
} | ||
} |