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)); } }