From d2beb3b8fd4a22e6026a605f6e91bdc2c6693e3d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 28 Feb 2017 05:36:02 +0300 Subject: [PATCH] added logger messages, still not sure about API... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/peer.js | 54 +++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/ui (gen4)/features/peer.js b/ui (gen4)/features/peer.js index 91248321..973dfd75 100755 --- a/ui (gen4)/features/peer.js +++ b/ui (gen4)/features/peer.js @@ -343,7 +343,59 @@ module.ChildProcessPeer = core.ImageGridFeatures.Feature({ // parent... ['start', function(){ - // XXX + var that = this + process.on('message', function(msg){ + // Handle action call... + // + // Format: + // { + // type: 'action-call', + // + // id: , + // + // action: , + // + // args: [, .. ] | null, + // + // ignore_return: , + // } + if(msg.type == 'action-call' && msg.action in that){ + var res = that[msg.action].apply(that, msg.args || []) + + if(!msg.ignore_return){ + process.send({ + type: 'action-call-result', + id: msg.id, + value: res === that ? null : res, + }) + } + + // Handle action call result... + // + // Format: + // { + // type: 'action-call-result', + // id: , + // value: | null, + // } + } else if(msg.type == 'action-call-result'){ + var callback = (this.__peer_result_callbacks || {})[msg.id] + + callback + && (delete this.__peer_result_callbacks[msg.id]) + && callback(msg.value) + + // Handle logger calls... + // + // Format: + // { + // type: 'logger-emit', + // value: [ .. ], + // } + } else if(msg.type == 'logger-emit' && this.logger){ + this.logger.emit.apply(this.logger, msg.value) + } + }) }], ], })