Added test for undeliverable volatile events for websocket.

This commit is contained in:
Guillermo Rauch
2011-05-22 13:02:13 -07:00
parent 8c9e6a99bc
commit 9b8ca8cc4b

View File

@@ -280,6 +280,52 @@ module.exports = {
}, 10);
};
ws.on('message', function () {
messaged = true;
});
});
},
'test sending undeliverable volatile events': function (done) {
var cl = client(++ports)
, io = create(cl)
, messaged = false
, s;
io.configure(function () {
io.set('close timeout', .05);
});
io.sockets.on('connection', function (socket) {
s = socket;
socket.on('disconnect', function () {
messaged.should.be.false;
cl.end();
io.server.close();
done();
});
});
cl.handshake(function (sid) {
var ws = websocket(cl, sid);
ws.onopen = function () {
ws.finishClose();
setTimeout(function () {
s.volatile.emit({ a: 'b' });
ws = websocket(cl, sid);
ws.on('message', function () {
messaged = true;
});
setTimeout(function () {
ws.finishClose();
}, 10);
}, 10);
};
ws.on('message', function () {
messaged = true;
});