lib/controllers/heartbeat.js
function HeartbeatController(client, sourceId, destinationId) {
  JsonController.call(this, client, sourceId, destinationId, 'urn:x-cast:com.google.cast.tp.heartbeat');

  this.pingTimer = null;
  this.timeout = null;
  this.intervalValue = DEFAULT_INTERVAL;

  this.on('message', onmessage);
  this.once('close', onclose);

  var self = this;

  function onmessage(data, broadcast) {
    if(data.type === 'PONG') {
      self.emit('pong');
    }
  }

  function onclose() {
    self.removeListener('message', onmessage);
    self.stop();
  }
  
}
function HeartbeatController(client, sourceId, destinationId) {
  JsonController.call(this, client, sourceId, destinationId, 'urn:x-cast:com.google.cast.tp.heartbeat');

  this.pingTimer = null;
  this.timeout = null;
  this.intervalValue = DEFAULT_INTERVAL;

  this.on('message', onmessage);
  this.once('close', onclose);

  var self = this;

  function onmessage(data, broadcast) {
    if(data.type === 'PONG') {
      self.emit('pong');
    }
  }

  function onclose() {
    self.removeListener('message', onmessage);
    self.stop();
  }
  
}
function HeartbeatController ( client , sourceId , destinationId ) { JsonController . call ( this , client , sourceId , destinationId , 'urn:x-cast:com.google.cast.tp.heartbeat' ) ; this . pingTimer = null ; this . timeout = null ; this . intervalValue = DEFAULT_INTERVAL ; this . on ( 'message' , onmessage ) ; this . once ( 'close' , onclose ) ; var self = this ; function onmessage ( data , broadcast ) { if ( data . type === 'PONG' ) { self . emit ( 'pong' ) ; } } function onclose ( ) { self . removeListener ( 'message' , onmessage ) ; self . stop ( ) ; } }
timeouts after 3 intervals
timeouts after 3 intervals