diff --git a/HISTORY.md b/HISTORY.md index a37b600..11c2cba 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 diff --git a/index.js b/index.js index 63795a0..1118fb4 100644 --- a/index.js +++ b/index.js @@ -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; } @@ -168,6 +169,10 @@ MsgServer.prototype.setupMessageStream = function (cfg) { } }); + if (this.sessionKey) { + stream.setSessionKey(this.sessionKey); + } + this.stream = stream; return true; @@ -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); };