Skip to content

Commit

Permalink
Added testcase to prevent socketio#374 from happening again
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Jul 24, 2011
1 parent 8b22ca2 commit b694ee6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/transports.websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,42 @@ module.exports = {
});
},

'test accessing handshake data from sockets on disconnect': function (done) {
var cl = client(++ports)
, io = create(cl)
, ws;

io.sockets.on('connection', function (socket) {
socket.on('disconnect', function () {

(!!socket.handshake.address.address).should.be.true;
(!!socket.handshake.address.port).should.be.true;
socket.handshake.headers.host.should.equal('localhost');
socket.handshake.headers.connection.should.equal('keep-alive');
socket.handshake.time.should.match(/GMT/);

setTimeout(function () {
ws.finishClose();
cl.end();
io.server.close();
done();
}, 10);
});

socket.disconnect();
});

cl.handshake(function (sid) {
ws = websocket(cl, sid);
ws.on('message', function (msg) {
if (!ws.connected) {
msg.type.should.eql('connect');
ws.connected = true;
}
});
});
},

'test for intentional and unintentional disconnects': function (done) {
var cl = client(++ports)
, io = create(cl)
Expand Down

0 comments on commit b694ee6

Please sign in to comment.