<commit_before>var cadence = require('cadence')
var Conduit = require('conduit/conduit')

function Run (olio) {
    this._olio = olio
}

Run.prototype.connect = cadence(function (async, destructible, inbox, outbox) {
    destructible.monitor('conduit', Conduit, inbox, outbox, cadence(function (async, request, inbox, outbox) {
        return [ 1 ]
    }), async())
})

Run.prototype.message = cadence(function (async, envelope) {
    if (envelope.body.method == 'send') {
        this._olio.broadcast('serve', { method: 'broadcast', sequence: envelope.body.sequence }, async())
    }
})

Run.prototype.reconfigure = cadence(function () {
    // TODO Someday.
})

// TODO No, we do not wait for all message to complete before exit, we just
// exit, that's where we're at. Or maybe, it is always the client that hangs up
// on the server and we're bi-directional then all the hangups will wind down a
// multiplexer.

// TODO Looks like you are getting ever more liberal with your use of
// `Destructible`. The wrapper will need to know how to handle incoming
// requests, so it needs a `receiver` function. If the child is going to call
// itself, then it needs to wait for the wrapper to get the `receiver` before it
// can create a sender on itself. We kind of had this apparent when Olio was
// constructed with a listener builder as an argument if it was going to be a
// server. Could pass in a builder.
module.exports = cadence(function (async, destructible, olio) {
    olio.on('application:request', function (message)  {
        olio.broadcast('serve', 'application:response', message)
    })
    console.log('RUN CALLED')
    return new Run(olio)
})
<commit_msg>Test `Olio.send`, `Olio.broadcast` after destroy.<commit_after>var cadence = require('cadence')
var Conduit = require('conduit/conduit')

function Run (olio) {
    this._olio = olio
}

Run.prototype.connect = cadence(function (async, destructible, inbox, outbox) {
    destructible.monitor('conduit', Conduit, inbox, outbox, cadence(function (async, request, inbox, outbox) {
        return [ 1 ]
    }), async())
})

Run.prototype.message = cadence(function (async, envelope) {
    if (envelope.body.method == 'send') {
        this._olio.broadcast('serve', { method: 'broadcast', sequence: envelope.body.sequence }, async())
    }
})

Run.prototype.reconfigure = cadence(function () {
    // TODO Someday.
})

// TODO No, we do not wait for all message to complete before exit, we just
// exit, that's where we're at. Or maybe, it is always the client that hangs up
// on the server and we're bi-directional then all the hangups will wind down a
// multiplexer.

// TODO Looks like you are getting ever more liberal with your use of
// `Destructible`. The wrapper will need to know how to handle incoming
// requests, so it needs a `receiver` function. If the child is going to call
// itself, then it needs to wait for the wrapper to get the `receiver` before it
// can create a sender on itself. We kind of had this apparent when Olio was
// constructed with a listener builder as an argument if it was going to be a
// server. Could pass in a builder.
module.exports = cadence(function (async, destructible, olio) {
    olio.on('application:request', function (message)  {
        olio.broadcast('serve', 'application:response', message)
    })
    console.log('RUN CALLED')
    destructible.destruct.wait(function () {
        // This is an example of a test that I know is working only through
        // coverage. I'd have to add instrumentation to know it worked, also
        // maybe print my TAP test `ok` directly to standard out here.
        setImmediate(function () {
            olio.broadcast('serve', 'application:dropped', {})
            olio.send('serve', 0, 'application:dropped', {})
            olio.send('serve', 0, 'application:dropped', {}, {
                destroy: function () {}
            })
        })
    })
    return new Run(olio)
})

{'fraction_non_alphanumeric': 0.11612576064908722, 'fraction_numerical': 0.0010141987829614604, 'mean_word_length': 3.302071973827699, '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': '5032202', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1128, 'n_words': 444}