Permalink
Browse files

Merge pull request #680 from FredyC/add-auto-connect

Add autoConnect option
  • Loading branch information...
2 parents 3340d6e + 77fd9d1 commit f8afcce0078fc79892c49847647270a648e9f5a8 @rauchg rauchg committed Jun 22, 2014
Showing with 9 additions and 1 deletion.
  1. +2 −0 README.md
  2. +2 −1 lib/manager.js
  3. +5 −0 test/connection.js
View
@@ -89,6 +89,8 @@ Socket.IO is compatible with [browserify](http://browserify.org/).
the amount specified by `reconnectionDelay`.
- `timeout` connection timeout before a `connect_error`
and `connect_timeout` events are emitted (`20000`)
+ - `autoConnect` by setting this false, you have to call `manager.open`
+ whenever you decide it's appropriate
#### Events
View
@@ -52,7 +52,8 @@ function Manager(uri, opts){
this.packetBuffer = [];
this.encoder = new parser.Encoder();
this.decoder = new parser.Decoder();
- this.open();
+ if (opts.autoConnect !== false)
+ this.open();
}
/**
View
@@ -15,6 +15,11 @@ describe('connection', function() {
});
});
+ it('should not connect when autoConnect option set to false', function() {
+ var socket = io({autoConnect: false});
+ expect(socket.io.engine).to.not.be.ok();
+ });
+
it('should work with acks', function(done){
var socket = io({ forceNew: true });
socket.emit('ack');

0 comments on commit f8afcce

Please sign in to comment.