Permalink
Browse files

fix autoConnect option

  • Loading branch information...
1 parent 70087e8 commit 8cc2f574518eee1c35ffed226515facff1b28462 @nkzawa nkzawa committed Jul 15, 2014
Showing with 19 additions and 5 deletions.
  1. +2 −2 lib/manager.js
  2. +1 −1 lib/socket.js
  3. +16 −2 test/connection.js
View
@@ -52,8 +52,8 @@ function Manager(uri, opts){
this.packetBuffer = [];
this.encoder = new parser.Encoder();
this.decoder = new parser.Decoder();
- if (opts.autoConnect !== false)
- this.open();
+ this.autoConnect = opts.autoConnect !== false;
+ if (this.autoConnect) this.open();
}
/**
View
@@ -56,7 +56,7 @@ function Socket(io, nsp){
this.json = this; // compat
this.ids = 0;
this.acks = {};
- this.open();
+ if (this.io.autoConnect) this.open();
this.receiveBuffer = [];
this.sendBuffer = [];
this.connected = false;
View
@@ -16,9 +16,9 @@ describe('connection', function() {
});
it('should not connect when autoConnect option set to false', function() {
- var socket = io({autoConnect: false});
+ var socket = io({ forceNew: true, autoConnect: false });
expect(socket.io.engine).to.not.be.ok();
- });
+ });
it('should work with acks', function(done){
var socket = io({ forceNew: true });
@@ -86,6 +86,20 @@ describe('connection', function() {
});
});
+ it('should open a new namespace after connection gets closed', function(done){
+ var manager = io.Manager();
+ var socket = manager.socket('/');
+ socket.on('connect', function() {
+ socket.disconnect();
+ }).on('disconnect', function() {
+ var foo = manager.socket('/foo');
+ foo.on('connect', function() {
+ foo.disconnect();
+ done();
+ });
+ });
+ });
+
it('should reconnect by default', function(done){
var socket = io({ forceNew: true });
socket.io.on('reconnect', function() {

0 comments on commit 8cc2f57

Please sign in to comment.