Expose socket.transport

This commit is contained in:
Arnout Kazemier
2011-07-06 00:10:25 +02:00
parent 7257e1ec36
commit 9cfdb8ed97
2 changed files with 41 additions and 0 deletions

View File

@@ -1642,5 +1642,36 @@ module.exports = {
}
});
});
},
'accessing the transport type': function (done) {
var cl = client(++ports)
, io = create(cl)
, ws;
io.sockets.on('connection', function (socket) {
socket.transport.should.equal('websocket');
socket.on('disconnect', function () {
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;
}
});
});
}
};