Skip to content

Commit

Permalink
fix(link): emit detached event when force detached locally
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Aug 18, 2016
1 parent aa65f79 commit d2531ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var EventEmitter = require('events').EventEmitter,

debug = require('debug')('amqp10:link'),
u = require('./utilities'),
frames = require('./frames');
frames = require('./frames'),
errors = require('./errors');

function Link(session, handle, linkPolicy) {
this.policy = linkPolicy;
Expand Down Expand Up @@ -140,6 +141,10 @@ Link.prototype.forceDetach = function() {
debug('force detach for ' + this.name + '. current state: ' + state);
if (!!this._reattachTimer) clearTimeout(this._reattachTimer);
this.linkSM.forceDetach();
this.emit(Link.Detached, {
closed: true,
error: new errors.ProtocolError('amqp:link:detach-forced', 'detach-forced')
});
};

// private api
Expand Down
9 changes: 9 additions & 0 deletions test/integration/qpid/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,14 @@ describe('Client', function() {
});
});

it('should emit a detached event when link is force detached locally', function(done) {
test.client.connect(config.address)
.then(function() { return test.client.createReceiver(config.defaultLink); })
.then(function(link) {
link.on('detached', function() { done(); });
return test.client.disconnect();
});
});

});
});

0 comments on commit d2531ba

Please sign in to comment.