mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Remove unused router component
This commit is contained in:
		| @@ -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)); | ||||
|     } | ||||
| } | ||||
| @@ -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 | ||||
		Reference in New Issue
	
	Block a user