Permalink
Browse files

test writeBuffer isn't cleared onError, removed 'closing' check in .f…

…lush()
  • Loading branch information...
1 parent 89de5f5 commit 300b09600042789994e8b2dd9d719787ad69d792 @albertyfwu albertyfwu committed Mar 13, 2013
Showing with 4 additions and 7 deletions.
  1. +1 −4 lib/socket.js
  2. +3 −3 test/server.js
View
5 lib/socket.js
@@ -322,10 +322,7 @@ Socket.prototype.flush = function () {
this.emit('flush', this.writeBuffer);
this.server.emit('flush', this, this.writeBuffer);
var wbuf = this.writeBuffer;
- // Let developer have time to read the writeBuffer
- if ('closing' != this.readyState) {
- this.writeBuffer = [];
- }
+ this.writeBuffer = [];
if (!this.transport.supportsFraming) {
this.sentCallbackFn.push(this.packetsFn)
} else {
View
6 test/server.js
@@ -234,16 +234,16 @@ describe('server', function () {
socket.sendPacket = function (){};
engine.on('connection', function (conn) {
conn.on('close', function (reason) {
- expect(conn.writeBuffer.length).to.be(2); // has close packet
+ expect(conn.writeBuffer.length).to.be(1);
setTimeout(function () {
expect(conn.writeBuffer.length).to.be(0); // writeBuffer has been cleared
}, 10);
+ done();
});
conn.writeBuffer.push({ type: 'message', data: 'foo'});
- conn.close();
+ conn.onError('');
});
});
- done();
});
it('should trigger on server if the client does not pong', function (done) {

0 comments on commit 300b096

Please sign in to comment.