diff --git a/lib/client.js b/lib/client.js index c6b851f..30a7e0d 100644 --- a/lib/client.js +++ b/lib/client.js @@ -243,6 +243,10 @@ StompClient.prototype.onConnect = function() { 'passcode': self.pass }; + if (this.version !== '1.0') { + headers['accept-version'] = Object.keys(StompFrameCommands).join(','); + } + if(this.vhost && this.version === '1.1') headers.host = this.vhost; diff --git a/test/client.test.js b/test/client.test.js index ffa5369..aae36e4 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -171,6 +171,28 @@ module.exports = testCase({ }, + 'send accept-version header on CONNECT when using version > 1.0': function(test) { + var self = this; + test.expect(2); + + sendHook = function(stompFrame) { + test.equal(stompFrame.command, 'CONNECT'); + test.deepEqual(stompFrame.headers, { + login: 'user', + passcode: 'pass', + 'accept-version': '1.0,1.1' + }); + + test.done(); + }; + + //start the test + this.stompClient.version = '1.1'; + this.stompClient.connect(); + connectionObserver.emit('connect'); + + }, + 'check inbound CONNECTED frame parses correctly': function(test) { var self = this; var testId = '1234';