Comparing version 0.4.17 to 0.4.18
@@ -10,6 +10,6 @@ { | ||
"engines": { | ||
"node": "~0.6.8" | ||
"node": ">0.4.0" | ||
}, | ||
"dependencies": { | ||
"express": "latest" | ||
"express": "2.x" | ||
}, | ||
@@ -16,0 +16,0 @@ "devDependencies": {}, |
@@ -7,2 +7,3 @@ var WebSocketServer = require('../../').Server | ||
app.use(express.static(__dirname + '/public')); | ||
app.listen(8080); | ||
@@ -12,3 +13,3 @@ var wss = new WebSocketServer({server: app}); | ||
var id = setInterval(function() { | ||
ws.send(JSON.stringify(process.memoryUsage())); | ||
ws.send(JSON.stringify(process.memoryUsage()), function() { /* ignore errors */ }); | ||
}, 100); | ||
@@ -21,3 +22,1 @@ console.log('started client interval'); | ||
}); | ||
app.listen(8080); |
@@ -0,1 +1,7 @@ | ||
v0.4.18 - June 14th 2012 | ||
===================== | ||
* Fixed incorrect md5 digest encoding in Hixie handshake [nicokaiser] | ||
* Added example of use with Express 3 [einaros] | ||
* Change installation procedure to not require --ws:native to build native extensions. They will now build if a compiler is available. [einaros] | ||
v0.4.17 - June 13th 2012 | ||
@@ -2,0 +8,0 @@ ===================== |
var spawn = require('child_process').spawn | ||
, exec = require('child_process').exec; | ||
, exec = require('child_process').exec | ||
, tinycolor = require('tinycolor') | ||
, fs = require('fs') | ||
, version = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8')).version | ||
, verbose = process.env['npm_package_config_verbose'] != null ? process.env['npm_package_config_verbose'] === 'true' : false; | ||
var build_native = process.env['npm_package_config_native'] != null ? process.env['npm_package_config_native'] : 'false'; | ||
build_native = build_native == 'true' ? true : false; | ||
if(build_native) { | ||
process.stdout.write("================================================================================\n"); | ||
process.stdout.write("= =\n"); | ||
process.stdout.write("= Building WS with blazing fast native extensions. =\n"); | ||
process.stdout.write("= =\n"); | ||
process.stdout.write("================================================================================\n"); | ||
console.log('[ws v%s]'.blue + ' Attempting to compile blazing fast native extensions.'.green, version); | ||
var gyp = exec('node-gyp rebuild', {cwd: __dirname}); | ||
gyp.stdout.on('data', function(data) { | ||
process.stdout.write(data); | ||
}); | ||
gyp.stderr.on('data', function(data) { | ||
process.stdout.write(data); | ||
}); | ||
gyp.on('exit', function(code) { | ||
process.exit(code); | ||
}); | ||
} | ||
else { | ||
process.stdout.write("================================================================================\n"); | ||
process.stdout.write("= =\n"); | ||
process.stdout.write("= To install WS with blazing fast native extensions, use =\n"); | ||
process.stdout.write("= <npm install ws --ws:native> =\n"); | ||
process.stdout.write("= =\n"); | ||
process.stdout.write("================================================================================\n"); | ||
} | ||
var gyp = exec('node-gyp rebuild', {cwd: __dirname}); | ||
gyp.stdout.on('data', function(data) { | ||
if (verbose) process.stdout.write(data); | ||
}); | ||
gyp.stderr.on('data', function(data) { | ||
if (verbose) process.stdout.write(data); | ||
}); | ||
gyp.on('exit', function(code) { | ||
if (code !== 0) { | ||
console.log('[ws v%s]'.blue + ' Native extension compilation failed.'.red, version); | ||
console.log('[ws v%s]'.blue + ' On Windows, native extensions require Visual Studio and Python.'.red, version); | ||
console.log('[ws v%s]'.blue + ' On Unix, native extensions require Python, make and a C++ compiler.'.red, version); | ||
console.log('[ws v%s]'.blue + ' Start npm with --ws:verbose to show compilation output (if any).'.red, version); | ||
} | ||
else { | ||
console.log('[ws v%s]'.blue + ' Native extension compilation successful!'.green, version); | ||
} | ||
process.exit(); | ||
}); |
@@ -43,3 +43,3 @@ /*! | ||
}); | ||
this._server.listen(options.value.port, options.value.host || '127.0.0.1', callback); | ||
this._server.listen(options.value.port, options.value.host, callback); | ||
this._closeServer = function() { self._server.close(); }; | ||
@@ -318,3 +318,3 @@ this._server.once('listening', function() { self.emit('listening'); }); | ||
var headerBuffer = new Buffer(headers.concat('', '').join('\r\n')); | ||
var hashBuffer = new Buffer(md5.digest('binary')); | ||
var hashBuffer = new Buffer(md5.digest('binary'), 'binary'); | ||
var handshakeBuffer = new Buffer(headerBuffer.length + hashBuffer.length); | ||
@@ -321,0 +321,0 @@ headerBuffer.copy(handshakeBuffer, 0); |
@@ -5,3 +5,3 @@ { | ||
"description": "simple to use, blazing fast and thoroughly tested websocket client, server and console for node.js, up-to-date against RFC-6455", | ||
"version": "0.4.17", | ||
"version": "0.4.18", | ||
"repository": { | ||
@@ -22,6 +22,7 @@ "type": "git", | ||
"config": { | ||
"native" : false | ||
"verbose" : false | ||
}, | ||
"dependencies": { | ||
"commander": "0.5.x", | ||
"tinycolor": "0.x", | ||
"options": "latest" | ||
@@ -34,5 +35,4 @@ }, | ||
"benchmark": "0.3.x", | ||
"tinycolor": "0.x", | ||
"ansi": "latest" | ||
} | ||
} |
@@ -66,2 +66,26 @@ [![Build Status](https://secure.travis-ci.org/einaros/ws.png)](http://travis-ci.org/einaros/ws) | ||
### Error handling best practices ### | ||
```js | ||
// If the WebSocket is closed before the following send is attempted | ||
ws.send('something'); | ||
// Errors (both immediate and async write errors) can be detected in an optional callback. | ||
// The callback is also the only way of being notified that data has actually been sent. | ||
ws.send('something', function(error) { | ||
// if error is null, the send has been completed, | ||
// otherwise the error object will indicate what failed. | ||
}); | ||
// Immediate errors can also be handled with try/catch-blocks, but **note** | ||
// that since sends are inherently asynchronous, socket write failures will *not* | ||
// be captured when this technique is used. | ||
try { | ||
ws.send('something'); | ||
} | ||
catch (e) { | ||
// handle error | ||
} | ||
``` | ||
### echo.websocket.org demo ### | ||
@@ -101,2 +125,4 @@ | ||
Note that the usage together with Express 3.0 is quite different from Express 2.x. The difference is expressed in the two different serverstats-examples. | ||
Otherwise, see the test cases. | ||
@@ -112,10 +138,2 @@ | ||
## Todos ## | ||
* Expose Sender and Receiver configuration options through WebSocket, and test that properly. | ||
* Cleanup configuration for Sender, and add similar bits to Receiver. | ||
* Either expose a configurable setting indicating favoring speed or memory use, or do a timer based shrink of Receiver's pools. | ||
* Make necessary changes to also support the even older hixie-75? Or at least write a few more tests for Hixie-76 to verify that fragmented nonce transfers really work. | ||
## License ## | ||
@@ -122,0 +140,0 @@ |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
229591
5
58
5814
160
3
7
15
+ Addedtinycolor@0.x
+ Addedtinycolor@0.0.1(transitive)