diff --git a/lib/link.js b/lib/link.js index c2d6733..0587973 100644 --- a/lib/link.js +++ b/lib/link.js @@ -14,7 +14,7 @@ function Link(session, handle, linkPolicy) { this.policy = linkPolicy; this.session = session; this.handle = handle; - this.remoteHandle = undefined; + this.remote = { handle: undefined }; this._onAttach = []; if (this.policy && this.policy.reattach) { @@ -148,8 +148,10 @@ Link.prototype._attachReceived = function(attachFrame) { this.linkSM.attachReceived(); // process params. - this.remoteHandle = attachFrame.handle; - this.session._linksByRemoteHandle[this.remoteHandle] = this; + this.remote.handle = attachFrame.handle; + this.remote.attach = attachFrame; + + this.session._linksByRemoteHandle[this.remote.handle] = this; debug(this.name + ': attached CH=[' + this.session.channel + '=>' + attachFrame.channel + '], Handle=[' + this.handle + '=>' + attachFrame.handle + ']'); this.emit(Link.Attached, this); @@ -199,9 +201,10 @@ Link.prototype._detached = function(frame) { this.emit(Link.ErrorReceived, u.wrapProtocolError(frame.error)); } - if (this.remoteHandle !== undefined) { - delete this.session._linksByRemoteHandle[this.remoteHandle]; - this.remoteHandle = undefined; + this.remote.detach = frame; + if (this.remote.handle !== undefined) { + delete this.session._linksByRemoteHandle[this.remote.handle]; + this.remote.handle = undefined; } this.emit(Link.Detached, { closed: frame.closed, error: u.wrapProtocolError(frame.error) });