code: function Channel (id, socket) {
    var log = debug('webrtc-tree-overlay:channel(' + id + ')')
    this._log = log
    var self = this
    this.id = id
    this._socket = socket
      .on('data', function (data) {
        log('received data:')
        log(data.toString())
        var message = JSON.parse(data)
        if (message.type === 'DATA') {
          log('data: ' + message.data)
          self.emit('data', message.data)
        } else if (message.type === 'JOIN-REQUEST') {
          log('join-request: ' + JSON.stringify(message))
          self.emit('join-request', message)
        } else {
          throw new Error('Invalid message type on channel(' + id + ')')
        }
      })
      .on('connect', function () {
        self.emit('connect', self)
      })
      .on('close', function () {
        log('closing')
        self.emit('close')
      })
      .on('error', function (err) {
        log(err.message)
        log(err.stack)
      })
  }
docs: Wraps the WebRTC socket inside a channel to encapsulate the join-request protocol while allowing application-defined control protocols to be multiplexed