<commit_before>var	signaller = require('rtc/signaller').create({
        channel: 'test',
        host: location.origin || 'http://localhost:3000/'
    }),
    PeerConnection = require('rtc/peerconnection'),
    media = require('rtc/media'),
    localVideo = media();

// wait for ready event
signaller.once('ready', function() {
    console.log('ready');
});

signaller.on('peer:discover', function(peer) {
    var connection = signaller.dial(peer.id),
        videoElements = [];

    console.log('discovered peer: ' + peer.id);

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

    connection.on('stream:add', function(stream) {
        videoElements = videoElements.concat(media(stream).render('.zone.remote'));
    });

    // when the connection is closed, remove the streams
    connection.on('close', function() {
        // remove the video elements
        videoElements.splice(0).forEach(function(el) {
            el.parentNode.removeChild(el);
        });

        // release the connection reference
        connection = null;
    });
});

localVideo.render('.zone.local');<commit_msg>Added some potential api tweaks for super easy api<commit_after>var	signaller = require('rtc/signaller').create({
        channel: 'test',
        host: location.origin || 'http://localhost:3000/'
    }),
    media = require('rtc/media'),
    localVideo = media().render('.zone.local');

signaller.on('peer:discover', function(peer) {
    var connection = signaller.dial(peer.id),
        videoElements = [];

    /* some potential nodey apis

    // send the local video to the connection
    localVideo.pipe(connection.createInput());

    // send connection streams to the media
    connection.createOutput().pipe(media.inject('.zone.remote'));
    */

    /* some potential more traditional apis

    connection.attach(localVideo);
    connection.renderTo('.zone.remote');
    */

    console.log('discovered peer: ' + peer.id);

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

    connection.on('stream:add', function(stream) {
        videoElements = videoElements.concat(media(stream).render('.zone.remote'));
    });

    // when the connection is closed, remove the streams
    connection.on('close', function() {
        // remove the video elements
        videoElements.splice(0).forEach(function(el) {
            el.parentNode.removeChild(el);
        });

        // release the connection reference
        connection = null;
    });
});
{'fraction_non_alphanumeric': 0.13712886440159167, 'fraction_numerical': 0.003060912151821243, 'mean_word_length': 2.7649769585253456, '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': '2916615', 'n_tokens_mistral': 877, 'n_tokens_neox': 863, 'n_words': 213}