Socket
Socket
Sign inDemoInstall

ws

Package Overview
Dependencies
Maintainers
1
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ws - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4-2

7

lib/WebSocket.js

@@ -304,2 +304,7 @@ /*!

var self = this;
socket.on('end', function() {
if (self._state == 'disconnected') return;
self._state = 'disconnected';
self.emit('close', self._closeCode || 1000, self._closeMessage || '');
});
socket.on('close', function() {

@@ -384,2 +389,2 @@ if (self._state == 'disconnected') return;

});
}
}

@@ -72,2 +72,8 @@ /*!

});
client.on('close', function() {
var index = self._clients.indexOf(client);
if (index != -1) {
self._clients.splice(index, 1);
}
});
});

@@ -77,2 +83,5 @@ this._server.listen(options.port, '127.0.0.1', function() {

});
this.__defineGetter__('clients', function() {
return self._clients;
});
}

@@ -97,3 +106,2 @@

this._clients[i].terminate();
// this._clients[i].close(code, data);
}

@@ -100,0 +108,0 @@ }

2

package.json

@@ -5,3 +5,3 @@ {

"description": "simple and very fast websocket protocol client for node.js",
"version": "0.3.3",
"version": "0.3.4-2",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -76,2 +76,3 @@ var assert = require('assert')

ws.on('close', function() {
srv.close();
done();

@@ -933,2 +934,2 @@ });

})
})
})

@@ -82,3 +82,3 @@ var assert = require('assert')

it('server can send data', function(done) {
it('can send data', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {

@@ -96,2 +96,45 @@ var ws = new WebSocket('ws://localhost:' + port);

})
})
describe('#clients', function() {
it('returns a list of connected clients', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {
wss.clients.length.should.eql(0);
var ws = new WebSocket('ws://localhost:' + port);
});
wss.on('connection', function(client) {
wss.clients.length.should.eql(1);
wss.close();
done();
});
})
it('is updated when client terminates the connection', function(done) {
var ws;
var wss = new WebSocketServer({port: ++port}, function() {
ws = new WebSocket('ws://localhost:' + port);
});
wss.on('connection', function(client) {
client.on('close', function() {
wss.clients.length.should.eql(0);
wss.close();
done();
});
ws.terminate();
});
})
it('is updated when client closes the connection', function(done) {
var ws;
var wss = new WebSocketServer({port: ++port}, function() {
ws = new WebSocket('ws://localhost:' + port);
});
wss.on('connection', function(client) {
client.on('close', function() {
wss.clients.length.should.eql(0);
wss.close();
done();
});
ws.close();
});
})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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