Socket
Socket
Sign inDemoInstall

castv2-client

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

castv2-client - npm Package Compare versions

Comparing version 0.0.8 to 1.1.0

38

lib/controllers/heartbeat.js

@@ -11,3 +11,3 @@ var util = require('util');

this.interval = null;
this.pingTimer = null;
this.timeout = null;

@@ -39,13 +39,21 @@ this.intervalValue = DEFAULT_INTERVAL;

this.once('pong', onpong);
function onpong() {
clearTimeout(self.timeout);
self.timeout = setTimeout(ontimeout, self.intervalValue * 1000 * TIMEOUT_FACTOR);
if (this.timeout) {
// We already have a ping in progress.
return;
}
function ontimeout() {
this.timeout = setTimeout(function ontimeout() {
self.emit('timeout');
}
}, self.intervalValue * 1000 * TIMEOUT_FACTOR);
this.once('pong', function onpong() {
clearTimeout(self.timeout);
self.timeout = null;
self.pingTimer = setTimeout(function() {
self.pingTimer = null;
self.ping();
}, self.intervalValue * 1000);
});
this.send({ type: 'PING' });

@@ -61,7 +69,2 @@ };

function oninterval() {
self.ping();
}
this.interval = setInterval(oninterval, this.intervalValue * 1000);
this.ping();

@@ -71,6 +74,11 @@ };

HeartbeatController.prototype.stop = function() {
clearInterval(this.interval);
clearTimeout(this.timeout);
if (this.pingTimer) {
clearTimeout(this.pingTimer);
}
if (this.timeout) {
clearTimeout(this.timeout);
}
this.removeAllListeners('pong');
};
module.exports = HeartbeatController;

@@ -50,2 +50,5 @@ var util = require('util');

if(err) return callback(err);
if(response.type === 'LAUNCH_ERROR') {
return callback(new Error('Launch failed. Reason: ' + response.reason));
}
callback(null, response.status.applications || []);

@@ -52,0 +55,0 @@ });

@@ -22,2 +22,7 @@ var util = require('util');

self.client.on('error', onerror);
function onerror(err) {
self.emit('error', err);
}
this.client.connect(options, function() {

@@ -31,3 +36,2 @@

self.client.on('error', onerror);
self.client.once('close', onclose);

@@ -39,6 +43,2 @@

function onerror(err) {
self.emit('error', err);
}
function onclose() {

@@ -45,0 +45,0 @@ self.heartbeat.stop();

{
"name": "castv2-client",
"version": "0.0.8",
"version": "1.1.0",
"description": "A Chromecast client based on the new (CASTV2) protocol",

@@ -5,0 +5,0 @@ "author": "thibauts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc