code: function (dispatchEvents, name) {
    this.dispatchEvent = dispatchEvents;
    this.name = name;
    this.connection = freedom['core.rtcpeerconnection']();
    this.connection.on(function (type, msg) {
      if (type === 'onsignalingstatechange' ||
          type === 'onnegotiationneeded' ||
          type === 'oniceconnectionstatechange') {
        this.dispatchEvent('message', '<small style="color:gray">' + type + '</small>');
      } else if (type === 'onicecandidate') {
        if (msg) {
          this.dispatchEvent('ice', JSON.stringify(msg));
        }
        this.dispatchEvent('message', '<small style="color:lightgray">Ice Candidate Produced</small>');
      } else if (type === 'ondatachannel') {
        this.dispatchEvent('message', '<small style="color:blue">Data Channel Ready [Recipient]</small>');
        this.channel = freedom['core.rtcdatachannel'](msg.channel);
        this.channel.on(this.onDataChannelMsg.bind(this));
      } else {
        this.dispatchEvent('message', JSON.stringify({type: type, msg: msg}));
      }
    }.bind(this));
  }
docs: This is the root module of the datachannel freedom.js demo.
  It runs in an isolated thread with its own namespace,
  peerconnection and datachannel objects are provided through
  freedom.