mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-12 00:17:56 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a10dc8d92d | ||
|
|
2b216902e1 | ||
|
|
832b8fc6d9 | ||
|
|
a0056904c1 |
10
History.md
10
History.md
@@ -1,4 +1,14 @@
|
||||
|
||||
2.0.2 / 2017-06-01
|
||||
===================
|
||||
|
||||
* [fix] Fix timing issues with middleware (#2948)
|
||||
|
||||
2.0.1 / 2017-05-09
|
||||
===================
|
||||
|
||||
* [fix] Update path of client file (#2934)
|
||||
|
||||
2.0.0 / 2017-05-09
|
||||
===================
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ Server.prototype.serveClient = function(v){
|
||||
return require.resolve(file);
|
||||
};
|
||||
if (v && !clientSource) {
|
||||
clientSource = read(resolvePath( 'socket.io-client/dist/socket.io.min.js'), 'utf-8');
|
||||
clientSource = read(resolvePath( 'socket.io-client/dist/socket.io.js'), 'utf-8');
|
||||
try {
|
||||
clientSourceMap = read(resolvePath( 'socket.io-client/dist/socket.io.js.map'), 'utf-8');
|
||||
} catch(err) {
|
||||
@@ -323,7 +323,6 @@ Server.prototype.serve = function(req, res){
|
||||
debug('serve client source');
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
res.setHeader('ETag', expectedEtag);
|
||||
res.setHeader('X-SourceMap', 'socket.io.js.map');
|
||||
res.writeHead(200);
|
||||
res.end(clientSource);
|
||||
};
|
||||
|
||||
@@ -99,6 +99,8 @@ Namespace.prototype.initAdapter = function(){
|
||||
*/
|
||||
|
||||
Namespace.prototype.use = function(fn){
|
||||
debug('removing initial packet');
|
||||
delete this.server.eio.initialPacket;
|
||||
this.fns.push(fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -297,9 +297,10 @@ Socket.prototype.onconnect = function(){
|
||||
debug('socket connected - writing packet');
|
||||
this.nsp.connected[this.id] = this;
|
||||
this.join(this.id);
|
||||
// the CONNECT packet for the default namespace
|
||||
// has already been sent as an `initialPacket`
|
||||
if (this.nsp.name !== '/') {
|
||||
var skip = this.nsp.name === '/' && this.nsp.fns.length === 0;
|
||||
if (skip) {
|
||||
debug('packet already sent in initial handshake');
|
||||
} else {
|
||||
this.packet({ type: parser.CONNECT });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "socket.io",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.2",
|
||||
"description": "node.js realtime framework server",
|
||||
"keywords": [
|
||||
"realtime",
|
||||
@@ -28,7 +28,7 @@
|
||||
"engine.io": "~3.1.0",
|
||||
"object-assign": "~4.1.1",
|
||||
"socket.io-adapter": "~1.1.0",
|
||||
"socket.io-client": "2.0.0",
|
||||
"socket.io-client": "~2.0.2",
|
||||
"socket.io-parser": "~3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -87,6 +87,9 @@ describe('socket.io', function(){
|
||||
srv.set('authorization', function(o, f) { f(null, false); });
|
||||
|
||||
var socket = client(httpSrv);
|
||||
socket.on('connect', function(){
|
||||
expect().fail();
|
||||
});
|
||||
socket.on('error', function(err) {
|
||||
expect(err).to.be('Not authorized');
|
||||
done();
|
||||
@@ -2145,6 +2148,9 @@ describe('socket.io', function(){
|
||||
});
|
||||
srv.listen(function(){
|
||||
var socket = client(srv);
|
||||
socket.on('connect', function(){
|
||||
done(new Error('nope'));
|
||||
});
|
||||
socket.on('error', function(err){
|
||||
expect(err).to.be('Authentication error');
|
||||
done();
|
||||
@@ -2163,6 +2169,9 @@ describe('socket.io', function(){
|
||||
});
|
||||
srv.listen(function(){
|
||||
var socket = client(srv);
|
||||
socket.on('connect', function(){
|
||||
done(new Error('nope'));
|
||||
});
|
||||
socket.on('error', function(err){
|
||||
expect(err).to.eql({ a: 'b', c: 3 });
|
||||
done();
|
||||
@@ -2186,6 +2195,26 @@ describe('socket.io', function(){
|
||||
});
|
||||
});
|
||||
|
||||
it('should only call connection after (lengthy) fns', function(done){
|
||||
var srv = http();
|
||||
var sio = io(srv);
|
||||
var authenticated = false;
|
||||
|
||||
sio.use(function(socket, next){
|
||||
setTimeout(function () {
|
||||
authenticated = true;
|
||||
next();
|
||||
}, 300);
|
||||
});
|
||||
srv.listen(function(){
|
||||
var socket = client(srv);
|
||||
socket.on('connect', function(){
|
||||
expect(authenticated).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be ignored if socket gets closed', function(done){
|
||||
var srv = http();
|
||||
var sio = io(srv);
|
||||
|
||||
Reference in New Issue
Block a user