var faye = require('faye')
    path = require('path');

var configPath = path.join(__dirname, '..', '..', 'shared', 'config.json'),
    config = require(configPath),
    client = new faye.Client( fayeUrl(config.collector) );

client.subscribe('/trigger', function () {
  console.log('Trigger message received');
});

setInterval(heartbeat, config.heartbeatIntervalSecs * 1000);

// Tell everyone we're here
function heartbeat() {
  client.publish('/heartbeat', { id: '1', type: 'emitter' });
}

function fayeUrl(url) {
  return 'http://' + url.host + ':' + url.port + '/faye';
}
@@ -252,69 +252,79 @@
 r', 
-function () %7B%0A  console.log('Trigger message received');%0A%7D);%0A
+handleTrigger);%0A%0A// Send a heartbeat every few secs (defined in config)
 %0Aset
@@ -581,8 +581,81 @@
 faye';%0A%7D
+%0A%0Afunction handleTrigger() %7B%0A  console.log('Trigger message received');%0A%7D

Handle trigger in own function