-
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 an example of a plugins mechanism
Part of #2035, investigating how we might implement the upcoming LiveObjects SDK as a plugin to the core SDK. The code here is consumed by the following proof of concepts: - LiveObjects plugin [1] - demonstrates how to consume the APIs that this commit exposes - LiveObjects example [2] - demonstrates how a user would use the LiveObjects plugin [1] /~https://github.com/lawrence-forooghian/ably-cocoa-liveobjects-plugin [2] /~https://github.com/lawrence-forooghian/ably-cocoa-liveobjects-example
- Loading branch information
1 parent
0da2fec
commit c624de3
Showing
13 changed files
with
197 additions
and
6 deletions.
There are no files selected for viewing
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,22 @@ | ||
#import "APPluginAPI.h" | ||
#import "ARTRealtimeChannel+Plugins.h" | ||
|
||
@implementation APPluginAPI | ||
|
||
+ (void)setPluginDataValue:(nonnull id)value | ||
forKey:(nonnull NSString *)key | ||
channel:(nonnull ARTRealtimeChannel *)channel { | ||
[channel setPluginDataValue:value forKey:key]; | ||
} | ||
|
||
+ (nullable id)pluginDataValueForKey:(nonnull NSString *)key | ||
channel:(nonnull ARTRealtimeChannel *)channel { | ||
return [channel pluginDataValueForKey:key]; | ||
} | ||
|
||
+ (void)addPluginProtocolMessageListener:(APProtocolMessageListener)listener | ||
channel:(nonnull ARTRealtimeChannel *)channel { | ||
[channel addPluginProtocolMessageListener:listener]; | ||
} | ||
|
||
@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,24 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@class ARTRealtimeChannel; | ||
@protocol APLiveObjectsPluginProtocol; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
// The `AblyLiveObjects.Plugin` class will _informally_ conform to this (informally so that we don't have to expose this protocol publicly); we keep this protocol simple because there will be no compiler checking | ||
NS_SWIFT_NAME(LiveObjectsPluginFactoryProtocol) | ||
@protocol APLiveObjectsPluginFactoryProtocol <NSObject> | ||
|
||
+ (id<APLiveObjectsPluginProtocol>)createPlugin; | ||
|
||
@end | ||
|
||
// An internal class of `AblyLiveObjects` will conform to this; this protocol can be complex because compiler will check conformance | ||
NS_SWIFT_NAME(LiveObjectsPluginProtocol) | ||
@protocol APLiveObjectsPluginProtocol <NSObject> | ||
|
||
- (void)prepareChannel:(ARTRealtimeChannel *)channel; | ||
|
||
@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,27 @@ | ||
@import Foundation; | ||
|
||
@class ARTRealtimeChannel; | ||
@class ARTProtocolMessage; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
NS_SWIFT_NAME(ProtocolMessageListener) | ||
typedef void (^APProtocolMessageListener)(ARTProtocolMessage *); | ||
|
||
NS_SWIFT_NAME(PluginAPI) | ||
@interface APPluginAPI: NSObject | ||
|
||
+ (void)setPluginDataValue:(id)value | ||
forKey:(NSString *)key | ||
channel:(ARTRealtimeChannel *)channel; | ||
|
||
+ (nullable id)pluginDataValueForKey:(NSString *)key | ||
channel:(ARTRealtimeChannel *)channel; | ||
|
||
// Listener will be called each time a protocol message is received | ||
+ (void)addPluginProtocolMessageListener:(APProtocolMessageListener)listener | ||
channel:(ARTRealtimeChannel *)channel; | ||
|
||
@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 @@ | ||
../../Source/PrivateHeaders/Ably/ARTProtocolMessage.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
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
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,16 @@ | ||
#import <Ably/ARTRealtimeChannel.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef void (^ARTProtocolMessageListener)(ARTProtocolMessage *); | ||
|
||
@interface ARTRealtimeChannel () | ||
|
||
- (void)setPluginDataValue:(id)value forKey:(NSString *)key; | ||
- (nullable id)pluginDataValueForKey:(NSString *)key; | ||
|
||
- (void)addPluginProtocolMessageListener:(ARTProtocolMessageListener)listener; | ||
|
||
@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
Oops, something went wrong.