Comparing version 0.4.9 to 0.4.10
@@ -0,1 +1,6 @@ | ||
v0.4.10 - Mar 22th 2012 | ||
===================== | ||
* Final hixie close frame fixes. [nicokaiser] | ||
v0.4.9 - Mar 21st 2012 | ||
@@ -2,0 +7,0 @@ ===================== |
@@ -24,3 +24,3 @@ /*! | ||
}).bind(null, this); | ||
this._buffer = new Buffer(initialSize); | ||
this._buffer = initialSize ? new Buffer(initialSize) : null; | ||
this._offset = 0; | ||
@@ -27,0 +27,0 @@ this._used = 0; |
@@ -46,9 +46,16 @@ /*! | ||
function doAdd() { | ||
if (self.state == EMPTY && data[0] != 0x00) { | ||
self.error('payload must start with 0x00 byte', true); | ||
return; | ||
if (self.state === EMPTY) { | ||
if (data.length == 2 && data[0] == 0xFF && data[1] == 0x00) { | ||
self.reset(); | ||
self.emit('close'); | ||
return; | ||
} | ||
if (data[0] !== 0x00) { | ||
self.error('payload must start with 0x00 byte', true); | ||
return; | ||
} | ||
data = data.slice(1); | ||
self.state = BODY; | ||
} | ||
if (self.state === EMPTY) data = data.slice(1); | ||
self.buffers.push(data); | ||
if (self.state == EMPTY) self.state = BODY; | ||
if ((self.messageEnd = bufferIndex(data, 0xFF)) != -1) { | ||
@@ -84,4 +91,3 @@ self.spanLength += self.messageEnd; | ||
this.reset(); | ||
if (output == '') this.emit('close'); | ||
else this.emit('text', output.toString('utf8')); | ||
this.emit('text', output.toString('utf8')); | ||
return tail; | ||
@@ -88,0 +94,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.9", | ||
"version": "0.4.10", | ||
"repository": { | ||
@@ -28,2 +28,3 @@ "type": "git", | ||
"should": "0.4.2", | ||
"expect.js": "0.1.2", | ||
"benchmark": "0.3.x", | ||
@@ -30,0 +31,0 @@ "tinycolor": "0.x", |
@@ -39,2 +39,16 @@ var assert = require('assert') | ||
it('can parse empty message', function() { | ||
var p = new Receiver(); | ||
var packet = '00 ff'; | ||
var gotData = false; | ||
p.on('text', function(data) { | ||
gotData = true; | ||
assert.equal('', data); | ||
}); | ||
p.add(getBufferFromHexString(packet)); | ||
expect(gotData).to.equal(true); | ||
}); | ||
it('can parse text messages delivered over multiple frames', function() { | ||
@@ -101,3 +115,3 @@ var p = new Receiver(); | ||
var packets = [ | ||
'00 ff' | ||
'ff 00' | ||
]; | ||
@@ -104,0 +118,0 @@ |
@@ -507,3 +507,5 @@ var http = require('http') | ||
var wss = new WebSocketServer({port: ++port, verifyClient: function(o, cb) { | ||
cb(false); | ||
process.nextTick(function() { | ||
cb(false); | ||
}); | ||
}}, function() { | ||
@@ -539,3 +541,5 @@ var options = { | ||
var wss = new WebSocketServer({port: ++port, verifyClient: function(o, cb) { | ||
cb(true); | ||
process.nextTick(function() { | ||
cb(true); | ||
}); | ||
}}, function() { | ||
@@ -542,0 +546,0 @@ var options = { |
Sorry, the diff of this file is not supported yet
214280
5591
6