q-connection.js
function (message) {

            // forward the message to the local promise,
            // which will return a response promise
            var local = getLocal(message.to).promise;
            var response = local.dispatch(message.op, decode(message.args));
            var envelope;

            // connect the local response promise with the
            // remote response promise:

            // if the value is ever resolved, send the
            // fulfilled value across the wire
            response.then(function (resolution) {
                try {
                    resolution = encode(resolution);
                } catch (exception) {
                    try {
                        resolution = {"!": encode(exception)};
                    } catch (_exception) {
                        resolution = {"!": null};
                    }
                }
                envelope = JSON.stringify({
                    "type": "resolve",
                    "to": message.from,
                    "resolution": resolution
                });
                connection.put(envelope);
            }, function (reason) {
                try {
                    reason = encode(reason);
                } catch (exception) {
                    try {
                        reason = encode(exception);
                    } catch (_exception) {
                        reason = null;
                    }
                }
                envelope = JSON.stringify({
                    "type": "resolve",
                    "to": message.from,
                    "resolution": {"!": reason}
                });
                connection.put(envelope);
            }, function (progress) {
                try {
                    progress = encode(progress);
                    envelope = JSON.stringify({
                        "type": "notify",
                        "to": message.from,
                        "resolution": progress
                    });
                } catch (exception) {
                    try {
                        progress = {"!": encode(exception)};
                    } catch (_exception) {
                        progress = {"!": null};
                    }
                    envelope = JSON.stringify({
                        "type": "resolve",
                        "to": message.from,
                        "resolution": progress
                    });
                }
                connection.put(envelope);
            })
            .done();

        }
function (message) {

            // forward the message to the local promise,
            // which will return a response promise
            var local = getLocal(message.to).promise;
            var response = local.dispatch(message.op, decode(message.args));
            var envelope;

            // connect the local response promise with the
            // remote response promise:

            // if the value is ever resolved, send the
            // fulfilled value across the wire
            response.then(function (resolution) {
                try {
                    resolution = encode(resolution);
                } catch (exception) {
                    try {
                        resolution = {"!": encode(exception)};
                    } catch (_exception) {
                        resolution = {"!": null};
                    }
                }
                envelope = JSON.stringify({
                    "type": "resolve",
                    "to": message.from,
                    "resolution": resolution
                });
                connection.put(envelope);
            }, function (reason) {
                try {
                    reason = encode(reason);
                } catch (exception) {
                    try {
                        reason = encode(exception);
                    } catch (_exception) {
                        reason = null;
                    }
                }
                envelope = JSON.stringify({
                    "type": "resolve",
                    "to": message.from,
                    "resolution": {"!": reason}
                });
                connection.put(envelope);
            }, function (progress) {
                try {
                    progress = encode(progress);
                    envelope = JSON.stringify({
                        "type": "notify",
                        "to": message.from,
                        "resolution": progress
                    });
                } catch (exception) {
                    try {
                        progress = {"!": encode(exception)};
                    } catch (_exception) {
                        progress = {"!": null};
                    }
                    envelope = JSON.stringify({
                        "type": "resolve",
                        "to": message.from,
                        "resolution": progress
                    });
                }
                connection.put(envelope);
            })
            .done();

        }
function ( message ) { // forward the message to the local promise, // which will return a response promise var local = getLocal ( message . to ) . promise ; var response = local . dispatch ( message . op , decode ( message . args ) ) ; var envelope ; // connect the local response promise with the // remote response promise: // if the value is ever resolved, send the // fulfilled value across the wire response . then ( function ( resolution ) { try { resolution = encode ( resolution ) ; } catch ( exception ) { try { resolution = { "!" : encode ( exception ) } ; } catch ( _exception ) { resolution = { "!" : null } ; } } envelope = JSON . stringify ( { "type" : "resolve" , "to" : message . from , "resolution" : resolution } ) ; connection . put ( envelope ) ; } , function ( reason ) { try { reason = encode ( reason ) ; } catch ( exception ) { try { reason = encode ( exception ) ; } catch ( _exception ) { reason = null ; } } envelope = JSON . stringify ( { "type" : "resolve" , "to" : message . from , "resolution" : { "!" : reason } } ) ; connection . put ( envelope ) ; } , function ( progress ) { try { progress = encode ( progress ) ; envelope = JSON . stringify ( { "type" : "notify" , "to" : message . from , "resolution" : progress } ) ; } catch ( exception ) { try { progress = { "!" : encode ( exception ) } ; } catch ( _exception ) { progress = { "!" : null } ; } envelope = JSON . stringify ( { "type" : "resolve" , "to" : message . from , "resolution" : progress } ) ; } connection . put ( envelope ) ; } ) . done ( ) ; }
a "send" message forwards messages from a remote promise to a local promise.
a send message forwards messages from a remote promise to a local promise .