PusherChannel
@objcMembers
open class PusherChannel : NSObject
Undocumented
-
Undocumented
Declaration
Swift
open var eventHandlers: [String : [EventHandler]] { get set } -
Undocumented
Declaration
Swift
public var subscriptionCount: Int? { get } -
Undocumented
Declaration
Swift
open var subscribed: Bool -
Undocumented
Declaration
Swift
public let name: String -
Undocumented
Declaration
Swift
open weak var connection: PusherConnection? -
Undocumented
Declaration
Swift
open var unsentEvents: [QueuedClientEvent] -
Undocumented
Declaration
Swift
public let type: PusherChannelType -
Undocumented
Declaration
Swift
public var auth: PusherAuth? -
Undocumented
Declaration
Swift
open var onSubscriptionCountChanged: ((Int) -> Void)? -
Initializes a new PusherChannel with a given name and connection
Declaration
Swift
public init(name: String, connection: PusherConnection, auth: PusherAuth? = nil, onSubscriptionCountChanged: ((Int) -> Void)? = nil)Parameters
nameThe name of the channel
connectionThe connection that this channel is relevant to
authA PusherAuth value if subscription is being made to an authenticated channel without using the default auth methods
Return Value
A new PusherChannel instance
-
Binds a callback to a given event name, scoped to the PusherChannel the function is called on
Declaration
Swift
@discardableResult open func bind(eventName: String, eventCallback: @escaping (PusherEvent) -> Void) -> StringParameters
eventNameThe name of the event to bind to
eventCallbackThe function to call when a new event is received. The callback receives a PusherEvent, containing the event’s data payload and other properties.
Return Value
A unique callbackId that can be used to unbind the callback at a later time
-
Unbinds the callback with the given callbackId from the given eventName, in the scope of the channel being acted upon
Declaration
Swift
open func unbind(eventName: String, callbackId: String)Parameters
eventNameThe name of the event from which to unbind
callbackIdThe unique callbackId string used to identify which callback to unbind
-
Unbinds all callbacks from the channel
Declaration
Swift
open func unbindAll() -
Unbinds all callbacks for the given eventName from the channel
Declaration
Swift
open func unbindAll(forEventName eventName: String)Parameters
eventNameThe name of the event from which to unbind
-
Calls the appropriate callbacks for the given eventName in the scope of the acted upon channel
Declaration
Swift
open func handleEvent(event: PusherEvent)Parameters
eventThe event received from the websocket
-
If subscribed, immediately call the connection to trigger a client event with the given eventName and data, otherwise queue it up to be triggered upon successful subscription
Declaration
Swift
open func trigger(eventName: String, data: Any)Parameters
eventNameThe name of the event to trigger
dataThe data to be sent as the message payload
View on GitHub
PusherChannel Class Reference