# Channel

    @objc public class Channel: NSObject

A Channel is a discreet connection where multiple clients can communicate

- `isConnected`

  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

- `service`

  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!

- `delegate`

  The delegate for handling channel events

  #### Declaration

  Swift

      weak public var delegate: ChannelDelegate? = nil

- `connectionTimeout`

  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

- `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()

- `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])

- `connect(_:completionHandler:)`

  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

- `disconnect(_:)`

  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

- `disconnect()`

  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(event:message:)`

  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(event:message:data:)`

  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(event:message:target:)`

  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(event:message:data:target:)`

  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)

- `getClients()`

  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

- `on(_:performClosure:)`

  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

- `off(_:)`

  A convenience method to unsubscribe from notifications

  #### Declaration

  Swift

      public func off(observer: AnyObject)

  #### Parameters

  `observer` | The observer object to unregister observations

- `description`

  The description of the client

  #### Declaration

  Swift

      public override var description: String

© 2016 . All rights reserved. (Last updated: 2016-10-27)

Generated by jazzy ♪♫ v0.7.2, a Realm project.