<commit_before>(function() {
  var socket = io.connect('http://localhost:3000');
  var scope = rtc.signaller(socket, {
    dataEvent: 'message',
    openEvent: 'connect'
  });

  var peers = {};
  var localMedia;
  var debug = rtc.logger('helloworld');

  rtc.logger.enable('*');

  scope.on('open', function() {
    debug('scope open');
  });

  function createPeer(data) {
    var connection = rtc.createConnection();
    var videoElements = [];
    var coupling;

    debug('created peer for remote id: ' + data.id);

    // couple to the remote peer using the id over the signalling scope
    coupling = rtc.couple(connection, { id: data.id }, scope);
    coupling.once('active', function() {
      debug('connection active');
    });

    // if we already have a stream, then add the stream
    if (localMedia.stream) {
      debug('local video stream active, adding to the connection');
      connection.addStream(localMedia.stream);
    }
    // otherwise, wait for the start and bind
    else {
      localMedia.once('start', function(stream) {
        debug('local video has started streaming', stream);
        connection.addStream(stream);
      });
    }

    connection.addEventListener('addstream', function(evt) {
      debug('remote stream added', evt.stream);

      rtc.media(evt.stream).render('.zone.remote').forEach(function(el) {
        videoElements.push(el);
      });
    });

    connection.addEventListener('removestream', function(evt) {
      debug('remote stream removed');
    });

    return {
      connection: connection,
      videoElements: videoElements
    };
  }
  
  /* media setup */

  localMedia = rtc.media();

  // render the local stream
  localMedia.on('capture', function() {
    localMedia.render('.zone.local');
  });

  /* peer connection setup */

  scope.on('request', function() {
    debug(arguments);
  });

  // when another peer is discovered, try and communicate with it
  scope.on('announce', function(data) {<commit_msg>Handle capture event rather than start, demo stable<commit_after>(function() {
  var socket = io.connect('http://localhost:3000');
  var scope = rtc.signaller(socket, {
    dataEvent: 'message',
    openEvent: 'connect'
  });

  var peers = {};
  var localMedia;
  var debug = rtc.logger('helloworld');

  rtc.logger.enable('*');

  scope.on('open', function() {
    debug('scope open');
  });

  function createPeer(data) {
    var connection = rtc.createConnection();
    var videoElements = [];
    var coupling;

    debug('created peer for remote id: ' + data.id);

    // couple to the remote peer using the id over the signalling scope
    coupling = rtc.couple(connection, { id: data.id }, scope);
    coupling.once('active', function() {
      debug('connection active');
    });

    // if we already have a stream, then add the stream
    if (localMedia.stream) {
      debug('local video stream active, adding to the connection');
      connection.addStream(localMedia.stream);
    }
    // otherwise, wait for the start and bind
    else {
      localMedia.once('capture', function(stream) {
        debug('local video has started streaming', stream);
        connection.addStream(stream);
      });
    }

    connection.addEventListener('addstream', function(evt) {
      debug('remote stream added', evt.stream);

      rtc.media(evt.stream).render('.zone.remote').forEach(function(el) {
        videoElements.push(el);
      });
    });

    connection.addEventListener('removestream', function(evt) {
      debug('!!!! remote stream removed');
    });

    return {
      connection: connection,
      videoElements: videoElements
    };
  }
  
  /* media setup */

  localMedia = rtc.media();

  // render the local stream
  localMedia.on('capture', function() {
    localMedia.render('.zone.local');
  });

  /* peer connection setup */

  scope.on('request', function() {
    debug(arguments);
  });

  // when another peer is discovered, try and communicate with it
  scope.on('announce', function(data) {
{'fraction_non_alphanumeric': 0.1444250436517835, 'fraction_numerical': 0.001995510102269893, 'mean_word_length': 3.0220661985957875, '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': '5162013', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1119, 'n_words': 296}