Channel
@objc open class Channel: NSObject
A Channel is a discreet connection where multiple clients can communicate
-
The connection status of the channel
Declaration
Swift
open fileprivate(set) var isConnected: Bool = false
-
The uri of the channel (‘chat’)
Declaration
Swift
open fileprivate(set) var uri: String! = nil
-
the service that is suplaying the channel connection
Declaration
Swift
open fileprivate(set) var service : Service! = nil
-
The client that owns this channel instance
Declaration
Swift
open var me: ChannelClient!
-
Undocumented
Declaration
Swift
@objc open class Channel: NSObject
-
The delegate for handling channel events
Declaration
Swift
weak open var delegate: ChannelDelegate? = nil
-
The timeout for channel transport connection. The connection will be closed if no ping is received within the defined timeout
Declaration
Swift
open var connectionTimeout: TimeInterval = 5
-
Connects to the channel. This method will asynchronously call the delegate’s onConnect method and post a ChannelEvent.Connect notification upon completion. When a TV application connects to this channel, the onReady method/notification is also fired
Declaration
Swift
open func connect()
-
Connects to the channel. This method will asynchronously call the delegate’s onConnect method and post a ChannelEvent.Connect notification upon completion. When a TV application connects to this channel, the onReady method/notification is also fired
Declaration
Swift
open func connect(_ attributes: [String:String]?)
Parameters
attributes
Any attributes you want to associate with the client (ie. [“name”:“FooBar”])
-
Connects to the channel. This method will asynchronously call the delegate’s onConnect method and post a ChannelEvent.Connect notification upon completion. When a TV application connects to this channel, the onReady method/notification is also fired
Declaration
Swift
open func connect(_ attributes: [String:String]?, completionHandler: ((_ client: ChannelClient?, _ error: NSError?) -> Void)?)
Parameters
attributes
Any attributes you want to associate with the client (ie. [“name”:“FooBar”])
completionHandler
The callback handler
-
Disconnects from the channel. This method will asynchronously call the delegate’s onDisconnect and post a ChannelEvent.Disconnect notification upon completion.
client: The client that is disconnecting which is yourself
error: An error info if disconnect fails
Declaration
Swift
open func disconnect(_ completionHandler: ((_ client: ChannelClient?, _ error: NSError?) -> Void)?)
Parameters
completionHandler
The callback handler
-
Disconnects from the channel. This method will asynchronously call the delegate’s onDisconnect and post a ChannelEvent.Disconnect notification upon completion.
Declaration
Swift
open func disconnect()
-
Publish an event containing a text message payload
Declaration
Swift
open func publish(event: String, message: AnyObject?)
Parameters
event
The event name
message
A JSON serializable message object
-
Publish an event containing a text message and binary payload
Declaration
Swift
open func publish(event: String, message: AnyObject?, data: Data)
Parameters
event
The event name
message
A JSON serializable message object
data
Any binary data to send with the message
-
Publish an event with text message payload to one or more targets
Declaration
Swift
open func publish(event: String, message: AnyObject?, target: AnyObject)
Parameters
event
The event name
message
A JSON serializable message object
target
The target recipient(s) of the message.Can be a string client id, a collection of ids or a string MessageTarget (like MessageTarget.All.rawValue)
-
Publish an event containing a text message and binary payload to one or more targets
Declaration
Swift
open func publish(event: String, message: AnyObject?, data: Data, target: AnyObject )
Parameters
event
The event name
message
A JSON serializable message object
data
Any binary data to send with the message
target
The target recipient(s) of the message.Can be a string client id, a collection of ids or a string MessageTarget (like MessageTarget.All.rawValue)
-
A snapshot of the list of clients currently connected to the channel
Declaration
Swift
open func getClients() -> [ChannelClient]
Return Value
list of clients currently connected to the channel
-
A convenience method to subscribe for notifications using blocks.
Declaration
Swift
open func on(_ notificationName: String, performClosure:@escaping (Notification!) -> Void) -> AnyObject?
Parameters
notificationName
The name of the notification.
performClosure
The notification closure, which will be executed in the main thread. Make sure to control the ownership of a variables captured by the closure you provide in this parameter (e.g. use [unowned self] or [weak self] to make sure that self is released even if you did not unsubscribe from notification)
Return Value
An observer handler for removing/unsubscribing the block from notifications
-
A convenience method to unsubscribe from notifications
Declaration
Swift
open func off(_ observer: AnyObject)
Parameters
observer
The observer object to unregister observations
-
The description of the client
Declaration
Swift
open override var description: String
-
Undocumented
Declaration
Swift
@objc open class Channel: NSObject