Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ataraxia

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ataraxia - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

2

package.json
{
"name": "ataraxia",
"version": "0.3.2",
"version": "0.4.0",
"description": "P2P messaging over mesh networks",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,2 +8,4 @@ 'use strict';

const CURRENT_VERSION = 2;
module.exports = class Peer {

@@ -15,2 +17,3 @@ constructor(transport) {

this.events = new EventEmitter();
this.connected = false;

@@ -20,3 +23,3 @@ // Reply to hello messages with our metadata

this.id = msg.id;
this.version = msg.version;
this.version = Math.min(msg.version, CURRENT_VERSION);

@@ -30,4 +33,23 @@ this.debug = debug(ns + ':' + msg.id);

// Assume we are connected when hello is received
this.events.emit('connected');
if(this.version >= 2) {
// Setup a ping every 5 seconds
const pingInterval = 5000;
this.pingSender = setInterval(() => this.write('ping'), pingInterval);
this.pingTimeout = setTimeout(() => this.socket.destroy(), pingInterval * 4);
this.on('ping', () => {
if(! this.connected) {
// Consider the peer connected
this.connected = true;
this.events.emit('connected');
}
clearTimeout(this.pingTimeout);
this.pingTimeout = setTimeout(() => this.socket.destroy(), pingInterval * 4);
});
this.write('ping');
} else {
// Assume we are connected when hello is received
this.events.emit('connected');
}
});

@@ -72,2 +94,8 @@ }

clearTimeout(this.helloTimeout);
clearInterval(this.pingSender);
clearTimeout(this.pingTimeout);
this.connected = false;
this.events.emit('disconnected');

@@ -80,3 +108,3 @@ }

id: this.networkId,
version: 1
version: CURRENT_VERSION
});

@@ -83,0 +111,0 @@

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