New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chat

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chat - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

test/connection-removal.js

2

client.js

@@ -37,2 +37,4 @@ var MuxDemux = require('mux-demux'),

});
return stream;
};

@@ -39,0 +41,0 @@

2

package.json

@@ -10,3 +10,3 @@ {

],
"version": "0.4.3",
"version": "0.4.4",
"engines": {

@@ -13,0 +13,0 @@ "node": ">= 0.8.x < 0.9.0"

@@ -169,2 +169,6 @@ var debug = require('debug')('chat-room'),

// increment the count of streams for this connection
connection.streams = (connection.streams || 0) + 1;
// handle close events
stream.on('close', function() {

@@ -174,3 +178,11 @@ debug('stream closed - decoupling message handler');

// TODO: check the count of streams and if 0, remove the connection
// decrement the streams count
if (connection.streams) {
connection.streams -= 1;
}
// if we have no streams connected, then remove the connection
if (! connection.streams) {
room.connections.remove(id);
}
});

@@ -177,0 +189,0 @@

@@ -32,13 +32,15 @@ var assert = require('assert'),

it('should be able to capture messages coming via the connected stream', function(done) {
var client = chat.client(connections[0]);
var client = chat.client(room.connect());
client.once('data', function(msg) {
assert.equal(msg.data, 'hello');
assert.equal(msg.cid, connections[0].id);
client.once('data', function handleMessage(msg) {
if (msg.data === 'hello') {
room.removeListener('message', handleMessage);
done();
}
});
done();
client.identify({ nick: randomName().replace(/\s/g, '') }).on('ready', function() {
client.write('hello');
});
client.write('hello');
});
});
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