Example #1
0
Peer.prototype.disconnect = function () {
  this.emit('disconnected')
  if (this.subscriber) {
    this.subscriber.off()
  }
  this.removeAllListeners()
  this.session.off('singal', this.onSignal)
  wr.winResize.removeListener(this.onResize)
}
Example #2
0
Peer.prototype.listen = function () {
  this.onSignal = function (ev) {
    if (ev.type === 'signal:dimensionsChanged') {
      var dimensions = JSON.parse(ev.data)
      self.onRemoteDimensions(dimensions)
    }
  }
  this.session.on('signal', this.onSignal)

  // These listeners are defined here to keep them 'this-safe'
  var self = this
  this.onResize = function (dimensions) {
    self.emitLocalDimensions(dimensions)
  }
  wr.winResize.on(this.onResize)
  this.onResize()
}