<commit_before>/**
 * A FreeDOM interface to WebRTC Peer Connections
 */
var PeerConnection_unprivileged = function(channel) {
  this.channel = channel;
  this.identity = null;
  this.connection = null;
  handleEvents(this);
};

PeerConnection_unprivileged.prototype.open = function(proxy, id, continuation) {
  this.identity = fdom.Hub.get().
  continuation();
};

PeerConnection_unprivileged.prototype.postMessage = function(data, continuation) {
  if (!this.connection) {
    return continuation(false);
  }
  this.connection.send(data['text']);
  continuation();
};
<commit_msg>some additional framework for peerconnection<commit_after>/**
 * A FreeDOM interface to WebRTC Peer Connections
 */
var PeerConnection_unprivileged = function(channel) {
  this.channel = channel;
  this.identity = null;
  this.connection = null;
  handleEvents(this);
};

PeerConnection_unprivileged.prototype.open = function(proxy, id, continuation) {
  if (this.connection) {
    continuation(false);
  }

  this.identity = fdom.Hub.get();

  var RTCPeerConnection = RTCPeerConnection || webkitRTCPeerConnection || mozRTCPeerConnection;
  this.connection = new RTCPeerConnection(null, {'optional': [{'RtpDataChannels': true}]});

  this.connection.addEventListener('icecandidate', function(evt) {
    if(evt && evt['candidate']) {
      this.identity.postMessage({
        'action': 'method',
        'type': 'send',
        'value': [id, evt['candidate']]
      });
    }
  }, true);

  continuation();
};

PeerConnection_unprivileged.prototype.postMessage = function(data, continuation) {
  if (!this.connection) {
    return continuation(false);
  }
  this.connection.send(data['text']);
  continuation();
};

{'fraction_non_alphanumeric': 0.1403301886792453, 'fraction_numerical': 0.0, 'mean_word_length': 4.600660066006601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '118810', 'n_tokens_mistral': 530, 'n_tokens_neox': 512, 'n_words': 99}