Channel

@objc public class Channel: NSObject

A Channel is a discreet connection where multiple clients can communicate

  • The connection status of the channel

    Declaration

    Swift

    public private(set) var isConnected: Bool = false
  • uri

    The uri of the channel (‘chat’)

    Declaration

    Swift

    public private(set) var uri: String! = nil
  • the service that is suplaying the channel connection

    Declaration

    Swift

    public private(set) var service : Service! = nil
  • me

    The client that owns this channel instance

    Declaration

    Swift

    public var me: ChannelClient!
  • The delegate for handling channel events

    Declaration

    Swift

    weak public 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

    public var connectionTimeout: NSTimeInterval = 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

    public 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

    public 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

    public 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

    public 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

    public func disconnect()
  • Publish an event containing a text message payload

    Declaration

    Swift

    public func publish(event 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

    public func publish(event event: String, message: AnyObject?, data: NSData)

    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

    public func publish(event 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

    public func publish(event event: String, message: AnyObject?, data: NSData, 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

    public func getClients() -> [ChannelClient]

    Return Value

    list of clients currently connected to the channel

  • A convenience method to subscribe for notifications using blocks.

    Declaration

    Swift

    public func on(notificationName: String, performClosure:(NSNotification!) -> 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

    public func off(observer: AnyObject)

    Parameters

    observer

    The observer object to unregister observations

  • The description of the client

    Declaration

    Swift

    public override var description: String