src/index.js
/**
 * Establish the connection to the Refocus Real-Time application and add a
 * handler for the events associated with the specified namespace.
 *
 * @param opts
 */
Establish the connection to the Refocus Real-Time application and add a
handler for the events associated with the specified namespace.

@param opts
Establish the connection to the Refocus Real - Time application and add a handler for the events associated with the specified namespace . @param opts
function start(opts) {
  debug('Connecting to %s namespace "%s" with query id "%s"', opts.url,
    opts.namespace, opts.queryId)
  const socket = connect(opts)
  namespaceEvents[opts.namespace].forEach(eventType => {
    debug('Handling namespace "%s" event "%s"', opts.namespace, eventType)
    socket.on(eventType, (event) => {
      const jsonEvent = JSON.parse(event)
      const size = sizeof(jsonEvent)
      const obj = { namespace: opts.namespace, event: eventType, size}
      if (eventType === 'refocus.internal.realtime.sample.update') {
        obj.name = jsonEvent['refocus.internal.realtime.sample.update'].new.name
      } else if (eventType === 'refocus.internal.realtime.sample.nochange') {
        obj.name = jsonEvent['refocus.internal.realtime.sample.nochange'].name
      }
      debug('%o', obj)
      obj.message = jsonEvent[eventType]
      verbose('%o', obj)
    })
  })
  onDeath((signal) => {
    socket.disconnect()
    debug('Process terminated with signal %s', signal)
  })
} 
function start ( opts ) { debug ( 'Connecting to %s namespace "%s" with query id "%s"' , opts . url , opts . namespace , opts . queryId ) const socket = connect ( opts ) namespaceEvents [ opts . namespace ] . forEach ( eventType => { debug ( 'Handling namespace "%s" event "%s"' , opts . namespace , eventType ) socket . on ( eventType , ( event ) => { const jsonEvent = JSON . parse ( event ) const size = sizeof ( jsonEvent ) const obj = { namespace : opts . namespace , event : eventType , size } if ( eventType === 'refocus.internal.realtime.sample.update' ) { obj . name = jsonEvent [ 'refocus.internal.realtime.sample.update' ] . new . name } else if ( eventType === 'refocus.internal.realtime.sample.nochange' ) { obj . name = jsonEvent [ 'refocus.internal.realtime.sample.nochange' ] . name } debug ( '%o' , obj ) obj . message = jsonEvent [ eventType ] verbose ( '%o' , obj ) } ) } ) onDeath ( ( signal ) => { socket . disconnect ( ) debug ( 'Process terminated with signal %s' , signal ) } ) }
Establish the connection to the Refocus Real-Time application and add a
 handler for the events associated with the specified namespace.
Establish the connection to the Refocus Real - Time application and add a handler for the events associated with the specified namespace .
// Note: the event is transmitted as a string // Disconnect socket connection before exiting // start