Remove unused router component

This commit is contained in:
Nick O'Leary 2020-07-30 17:52:28 +01:00
parent bdd736315a
commit 27c0e45940
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 0 additions and 67 deletions

View File

@ -1,50 +0,0 @@
var settings;
const LocalRouter = require("./localRouter");
var defaultRouter;
class Router {
constructor(stack) {
this.stack = stack || [];
}
send(source,destinationId,msg) {
var pos = 0;
var next = () => {
var router = this.stack[pos++];
if (router) {
router.send(source,destinationId,msg,next);
}
}
next();
}
}
function init(runtime) {
settings = runtime.settings;
defaultRouter = new Router([
new LocalRouter(),
new PostMessageLogger()
])
}
function send(source,destinationId,msg) {
defaultRouter.send(source,destinationId,msg);
}
module.exports = {
init:init,
send: send
}
class PostMessageLogger {
constructor() {}
send(source,destinationId,msg,next) {
console.log(source.id.padEnd(16),"->",destinationId.padEnd(16),JSON.stringify(msg));
}
}

View File

@ -1,17 +0,0 @@
class LocalRouter {
constructor() {}
send(source,destinationId,msg,next) {
var node = source._flow.getNode(destinationId);
if (node) {
setImmediate(function() {
node.receive(msg);
next();
});
} else if (next) {
next()
}
}
}
module.exports = LocalRouter