Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

upnode event tests now pass

  • Loading branch information...
commit a9335d23b8fe6e1deeca8ab938b419e7db01f5cc 1 parent 3389aab
@substack authored
Showing with 14 additions and 4 deletions.
  1. +13 −3 index.js
  2. +1 −1  package.json
View
16 index.js
@@ -48,7 +48,10 @@ Airport.prototype.connect = function (role, fn) {
res = connector(s, function f (s_) {
res = connector(s_, f);
});
- target.close = function () { res.close() };
+ target.close = function () {
+ target.emit('close');
+ res.close();
+ };
queue.forEach(function (cb) { res(cb) });
queue = [];
}
@@ -71,16 +74,23 @@ Airport.prototype.connect = function (role, fn) {
else {
c = inst.connect(service, fn);
}
- c.on('down', function () { c.alive = false });
- c.on('up', function () {
+
+ c.on('down', function () {
+ c.alive = false;
+ target.emit('down');
+ });
+
+ c.on('up', function (remote) {
c.alive = true;
queue.forEach(function (f) { c(f) });
queue = [];
+ target.emit('up', remote);
});
var pending = false;
c.on('reconnect', function () {
if (pending) return;
+ target.emit('reconnect');
ports.get(role, function (ps) {
pending = false;
View
2  package.json
@@ -1,7 +1,7 @@
{
"name" : "airport",
"description" : "role-based port management for upnode",
- "version" : "0.3.2",
+ "version" : "0.3.3",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/airport.git"
Please sign in to comment.
Something went wrong with that request. Please try again.