<commit_before>/**
 * @class WebRtcContent
 *
 * @param {String} ws_uri: URI of the server WebSocket endpoint. Alternatively,
 *   it can be used a WebSocket or DataChannel object.
 */
function WebRtcContent(url, options)
{
  var self = this;


  // Initialize options and object status
  options = options || {};

  $.jsonRPC.setup({endPoint: url});

  var sessionId = null;
  var pollingTimeout = null;


  // Error dispatcher functions

  /**
   * Common function to dispatch the error to the user application
   *
   * @param {Error} error: error object to be dispatched
   */
  function onerror(error)
  {
    if(self.onerror)
       self.onerror(error);
  };

  /**
   * Adaptor from jsonRPC errors to standard Javascript Error objects
   *
   * @param response: jsonRPC error object
   */
  function onerror_jsonrpc(response)
  {
    onerror(new Error(response.error || response));
  };


  // Create the PeerConnection object
  var pc = new RTCPeerConnection(
  {
    iceServers: [{url: 'stun:'+'stun.l.google.com:19302'}]
  });

  // Add the local stream if defined
  if(options.stream)
    pc.addStream(options.stream);

  // Dispatch 'close' event if signaling gets closed
  pc.addEventListener('signalingState', function(event)
  {
    if(pc.signalingState == "close"
    && self.onclose)
       self.onclose(new Event('close'));
  });


  // RPC calls
<commit_msg>Setting event callback as property to work on Firefox v23<commit_after>/**
 * @class WebRtcContent
 *
 * @param {String} ws_uri: URI of the server WebSocket endpoint. Alternatively,
 *   it can be used a WebSocket or DataChannel object.
 */
function WebRtcContent(url, options)
{
  var self = this;


  // Initialize options and object status
  options = options || {};

  $.jsonRPC.setup({endPoint: url});

  var sessionId = null;
  var pollingTimeout = null;


  // Error dispatcher functions

  /**
   * Common function to dispatch the error to the user application
   *
   * @param {Error} error: error object to be dispatched
   */
  function onerror(error)
  {
    if(self.onerror)
       self.onerror(error);
  };

  /**
   * Adaptor from jsonRPC errors to standard Javascript Error objects
   *
   * @param response: jsonRPC error object
   */
  function onerror_jsonrpc(response)
  {
    onerror(new Error(response.error || response));
  };


  // Create the PeerConnection object
  var pc = new RTCPeerConnection(
  {
    iceServers: [{url: 'stun:'+'stun.l.google.com:19302'}]
  });

  // Add the local stream if defined
  if(options.stream)
    pc.addStream(options.stream);

  // Dispatch 'close' event if signaling gets closed
  pc.onsignalingstatechange = function(event)
  {
    if(pc.signalingState == "close"
    && self.onclose)
       self.onclose(new Event('close'));
  };


  // RPC calls

{'fraction_non_alphanumeric': 0.11697165410836025, 'fraction_numerical': 0.004305705059203444, 'mean_word_length': 3.1303703703703705, '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': '5355314', 'n_tokens_mistral': 899, 'n_tokens_neox': 842, 'n_words': 253}