lib/Connection.js
function BasicConnection() {
  var _this = this

  this._disconnected = false
  this._messageHandler = function() {
  }
  this._disconnectHandler = function() {
  }

  var childArgs = []

  process.execArgv.forEach(function(arg) {
    if (arg.indexOf('--debug-brk') !== -1) {
      var _debugPort = parseInt(arg.substr(12)) + 1
      debug('Child process debugger listening on port %d', _debugPort)
      childArgs.push('--debug-brk=' + _debugPort)
    }
  })

  this._process = child_process.fork(__dirname + '/../sandbox/sandbox.js', childArgs)

  this._startHeartBeat()

  this._process.on('message', function(data) {
    var m = codec.decode(data);
    debug('Recibing message: %j', m)
    _this._messageHandler(m)
  })

  this._process.on('exit', function(m) {
    debug('Exit process: %j', m)
    _this._stopHeartBeat()
    _this._disconnected = true
    _this._disconnectHandler(m)
  })
}
function BasicConnection() {
  var _this = this

  this._disconnected = false
  this._messageHandler = function() {
  }
  this._disconnectHandler = function() {
  }

  var childArgs = []

  process.execArgv.forEach(function(arg) {
    if (arg.indexOf('--debug-brk') !== -1) {
      var _debugPort = parseInt(arg.substr(12)) + 1
      debug('Child process debugger listening on port %d', _debugPort)
      childArgs.push('--debug-brk=' + _debugPort)
    }
  })

  this._process = child_process.fork(__dirname + '/../sandbox/sandbox.js', childArgs)

  this._startHeartBeat()

  this._process.on('message', function(data) {
    var m = codec.decode(data);
    debug('Recibing message: %j', m)
    _this._messageHandler(m)
  })

  this._process.on('exit', function(m) {
    debug('Exit process: %j', m)
    _this._stopHeartBeat()
    _this._disconnected = true
    _this._disconnectHandler(m)
  })
}
function BasicConnection ( ) { var _this = this this . _disconnected = false this . _messageHandler = function ( ) { } this . _disconnectHandler = function ( ) { } var childArgs = [ ] process . execArgv . forEach ( function ( arg ) { if ( arg . indexOf ( '--debug-brk' ) !== - 1 ) { var _debugPort = parseInt ( arg . substr ( 12 ) ) + 1 debug ( 'Child process debugger listening on port %d' , _debugPort ) childArgs . push ( '--debug-brk=' + _debugPort ) } } ) this . _process = child_process . fork ( __dirname + '/../sandbox/sandbox.js' , childArgs ) this . _startHeartBeat ( ) this . _process . on ( 'message' , function ( data ) { var m = codec . decode ( data ) ; debug ( 'Recibing message: %j' , m ) _this . _messageHandler ( m ) } ) this . _process . on ( 'exit' , function ( m ) { debug ( 'Exit process: %j' , m ) _this . _stopHeartBeat ( ) _this . _disconnected = true _this . _disconnectHandler ( m ) } ) }
Platform-dependent implementation of the BasicConnection
object, initializes the plugin site and provides the basic
messaging-based connection with it

For Node.js the plugin is created as a forked process
Platform - dependent implementation of the BasicConnection object initializes the plugin site and provides the basic messaging - based connection with it