Skip to content

Commit

Permalink
Merge pull request #2 from ronkorving/persistent-sessionkey
Browse files Browse the repository at this point in the history
Reconfiguring the message server no longer drops the session key.
  • Loading branch information
bjornstar committed Dec 17, 2014
2 parents c0b79f0 + 20ef4fb commit 0deb760
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# mage-message-server.js changelog

## v0.2.1
* Reconfiguring the message server no longer drops the session key.

## v0.2.0
* Moved message stream code into separate component

Expand Down
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function MsgServer(eventManager) {
this.futureLog = {}; // queues up events for soon or immediate emission
this.expectedMsgId = null;
this.stream = null;
this.sessionKey = null;

this.eventManager = eventManager;
}
Expand Down Expand Up @@ -168,6 +169,10 @@ MsgServer.prototype.setupMessageStream = function (cfg) {
}
});

if (this.sessionKey) {
stream.setSessionKey(this.sessionKey);
}

this.stream = stream;

return true;
Expand All @@ -181,7 +186,10 @@ MsgServer.prototype.setSessionKey = function (sessionKey) {

// Make sure any lingering messages are wiped out

this.resetFutureLog();
if (sessionKey !== this.sessionKey) {
this.resetFutureLog();
this.sessionKey = sessionKey;
}

this.stream.setSessionKey(sessionKey);
};
Expand Down

0 comments on commit 0deb760

Please sign in to comment.