mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
added logger messages, still not sure about API...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
16debe3cf4
commit
d2beb3b8fd
@ -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: <id>,
|
||||
//
|
||||
// action: <action-name>,
|
||||
//
|
||||
// args: [<arg>, .. ] | null,
|
||||
//
|
||||
// ignore_return: <bool>,
|
||||
// }
|
||||
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: <id>,
|
||||
// value: <object> | 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)
|
||||
}
|
||||
})
|
||||
}],
|
||||
],
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user