SKYPubsubClient

@interface SKYPubsubClient : NSObject

Undocumented

  • Undocumented

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic) NSURL *_Nullable endPointAddress;

    Swift

    var endPointAddress: URL? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic) NSString *_Nullable APIKey;

    Swift

    var apiKey: String? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) void (^)(void) onOpenCallback;

    Swift

    var onOpenCallback: (() -> Void)? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) void (^)(void) onCloseCallback;

    Swift

    var onCloseCallback: (() -> Void)? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) void (^)(NSError *_Nonnull)
        onErrorCallback;

    Swift

    var onErrorCallback: ((Error) -> Void)? { get set }
  • In normal usage, you will not need to init the PubsubClient by yourself. You just get the pubsubClient from the default SKYContainer and call the following:

    Subscribe a channel with handler [[SKYContainer defaultContainer].pubsubClient subscribeTo:@noteapp handler:^(NSDictionary *msg) { NSLog(@Got pubsub msg: %@, msg); }];

    Unsubscribe a channel [[SKYContainer defaultContainer].pubsubClient publishMessage:@{@note:@cool} toChannel:@noteapp];

    Declaration

    Objective-C

    - (nonnull instancetype)initWithEndPoint:(NSURL *_Nullable)endPoint
                                      APIKey:(NSString *_Nullable)APIKey;

    Swift

    init(endPoint: URL?, apiKey APIKey: String?)
  • Manually connect to the pubsub end-point without subscribing a channel. Normally, you can just

    Declaration

    Objective-C

    - (void)connect;

    Swift

    func connect()
  • Manually close pubsub conenction and unsubscribe everthings.

    Declaration

    Objective-C

    - (void)close;

    Swift

    func close()
  • Subscribe to channel with the messageHandler block. Each channel can only have one messageHandler.

    Declaration

    Objective-C

    - (void)subscribeTo:(nonnull NSString *)channel
                handler:(nonnull void (^)(NSDictionary *_Nonnull))messageHandler;

    Swift

    func subscribe(to channel: String, handler messageHandler: @escaping ([AnyHashable : Any]) -> Void)
  • Unscubscribe a channel without closing connection.

    Declaration

    Objective-C

    - (void)unsubscribe:(nonnull NSString *)channel;

    Swift

    func unsubscribe(_ channel: String)
  • Publish message to a channel.

    Declaration

    Objective-C

    - (void)publishMessage:(nonnull NSDictionary *)message
                 toChannel:(nonnull NSString *)channel;

    Swift

    func publishMessage(_ message: [AnyHashable : Any], toChannel channel: String)