<commit_before>var SimpleRelayConnections = require("./simpleRelayConnections")
    , RelayNetwork = require("../networks/relayNetwork")
    , PeerNetwork = require("../networks/peerNetwork")
    , EventEmitter = require("events").EventEmitter

module.exports = RelayStreams

function RelayStreams(conn, name, callback) {
    var rcs = SimpleRelayConnections(conn)
        , peerNetwork = PeerNetwork(conn, name + "/peer")
        , relayNetwork = RelayNetwork(conn, name + "/relay")
        , streams = new EventEmitter()
        
    // when you detect a new peer joining, open a RC to them
    peerNetwork.on("peer", handlePeer)

    // when we detect an offer from the relay network, open an RC to them
    relayNetwork.on("offer", handleOffer)

    // incoming answers from another peer
    relayNetwork.on("answer", rcs.handleAnswer)

    // handle streams coming out of rcs
    rcs.on("stream", callback)

    peerNetwork.join()

    streams.rcs = rcs
    streams.streams = rcs.streams
    streams.peerNetwork = peerNetwork
    streams.relayNetwork = relayNetwork
    streams.destroy = destroy

    return streams

    function handlePeer(remotePeerId) {
        var offer = rcs.create(remotePeerId)

        relayNetwork.sendOffer(remotePeerId, offer)
    }

    function handleOffer(remotePeerId, offer) {
        var answer = rcs.create(remotePeerId, offer)

        relayNetwork.sendAnswer(remotePeerId, answer)
    }

    function destroy() {
        rcs.destory()<commit_msg>oops typo<commit_after>var SimpleRelayConnections = require("./simpleRelayConnections")
    , RelayNetwork = require("../networks/relayNetwork")
    , PeerNetwork = require("../networks/peerNetwork")
    , EventEmitter = require("events").EventEmitter

module.exports = RelayStreams

function RelayStreams(conn, name, callback) {
    var rcs = SimpleRelayConnections(conn)
        , peerNetwork = PeerNetwork(conn, name + "/peer")
        , relayNetwork = RelayNetwork(conn, name + "/relay")
        , streams = new EventEmitter()
        
    // when you detect a new peer joining, open a RC to them
    peerNetwork.on("peer", handlePeer)

    // when we detect an offer from the relay network, open an RC to them
    relayNetwork.on("offer", handleOffer)

    // incoming answers from another peer
    relayNetwork.on("answer", rcs.handleAnswer)

    // handle streams coming out of rcs
    rcs.on("stream", callback)

    peerNetwork.join()

    streams.rcs = rcs
    streams.streams = rcs.streams
    streams.peerNetwork = peerNetwork
    streams.relayNetwork = relayNetwork
    streams.destroy = destroy

    return streams

    function handlePeer(remotePeerId) {
        var offer = rcs.create(remotePeerId)

        relayNetwork.sendOffer(remotePeerId, offer)
    }

    function handleOffer(remotePeerId, offer) {
        var answer = rcs.create(remotePeerId, offer)

        relayNetwork.sendAnswer(remotePeerId, answer)
    }

    function destroy() {
        rcs.destroy()
{'fraction_non_alphanumeric': 0.1009421265141319, 'fraction_numerical': 0.0, 'mean_word_length': 3.1177285318559558, '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': '4709598', 'n_tokens_mistral': 869, 'n_tokens_neox': 860, 'n_words': 212}