Skip to content

Commit

Permalink
Add connect event to Connection
Browse files Browse the repository at this point in the history
closes #1129
  • Loading branch information
dougwilson committed Jul 10, 2015
1 parent 1e982fb commit 6e05f06
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -6,6 +6,7 @@ you spot any mistakes.

## HEAD

* Add `connect` event to `Connection` #1129
* Fix a sync callback when sequence enqueue fails #1147
* Provide static require analysis
* Re-use connection from pool after `conn.changeUser` is used #837 #1088
Expand Down
1 change: 1 addition & 0 deletions lib/Connection.js
Expand Up @@ -382,6 +382,7 @@ Connection.prototype._handleProtocolDrain = function() {

Connection.prototype._handleProtocolConnect = function() {
this.state = "connected";
this.emit('connect');
};

Connection.prototype._handleProtocolHandshake = function _handleProtocolHandshake(packet) {
Expand Down
16 changes: 16 additions & 0 deletions test/unit/connection/test-connect-event.js
@@ -0,0 +1,16 @@
var assert = require('assert');
var common = require('../../common');
var connection = common.createConnection({port: common.fakeServerPort});

var server = common.createFakeServer();

server.listen(common.fakeServerPort, function (err) {
assert.ifError(err);

connection.on('connect', function () {
connection.destroy();
server.destroy();
});

connection.connect(assert.ifError);
});

0 comments on commit 6e05f06

Please sign in to comment.