From 3499721d8d4e4d14d146817fa800b01ac8ba8227 Mon Sep 17 00:00:00 2001 From: David Brenner Date: Tue, 8 Dec 2020 12:00:17 -0500 Subject: [PATCH 1/4] Update client.js Added support for specifying client-id in header on connect. --- lib/client.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index c6b851f..c95eded 100644 --- a/lib/client.js +++ b/lib/client.js @@ -52,7 +52,7 @@ var StompFrameCommands = { function StompClient(opts) { - var address, port, user, pass, protocolVersion, vhost, reconnectOpts, tlsOpts; + var address, port, user, pass, protocolVersion, vhost, reconnectOpts, tlsOpts, clientId; if(arguments.length !== 1 || typeof opts === 'string') { address = opts; @@ -66,6 +66,7 @@ function StompClient(opts) { if(tlsOpts === true) { tlsOpts = {}; } + clientId = arguments[8]; } else { address = opts.address || opts.host; @@ -80,6 +81,7 @@ function StompClient(opts) { if(tlsOpts === true) { tlsOpts = opts; } + clientId = opts.clientId; } events.EventEmitter.call(this); @@ -94,6 +96,7 @@ function StompClient(opts) { this.vhost = vhost || null; this.reconnectOpts = reconnectOpts || {}; this.tls = tlsOpts; + this.clientId = clientId || null; this._retryNumber = 0; this._retryDelay = this.reconnectOpts.delay; return this; @@ -246,6 +249,9 @@ StompClient.prototype.onConnect = function() { if(this.vhost && this.version === '1.1') headers.host = this.vhost; + if(this.clientId) + headers['client-id'] = this.clientId; + var frame = new StompFrame({ command: 'CONNECT', headers: headers From f0267e69602cff44cc58f2e667870718df41bf79 Mon Sep 17 00:00:00 2001 From: David Brenner Date: Tue, 8 Dec 2020 12:24:04 -0500 Subject: [PATCH 2/4] Update client.test.js Updated tests for added optional connect header clientId value. --- test/client.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/client.test.js b/test/client.test.js index ffa5369..8954a76 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -68,6 +68,7 @@ module.exports = testCase({ test.equal(stompClient.address, '127.0.0.1'); test.equal(stompClient.port, 61613); test.equal(stompClient.version, '1.0'); + test.equal(stompClient.clientId, null); test.done(); }, @@ -75,7 +76,7 @@ module.exports = testCase({ 'check StompClient construction from paremeters': function(test) { var stompClient = new StompClient( 'test.host.net',1234,'uname','pw', '1.1', 'q1.host.net', - { retries: 10, delay: 1000 }); + { retries: 10, delay: 1000 }, clientId: 'testclientid'); test.equal(stompClient.user, 'uname'); test.equal(stompClient.pass, 'pw'); @@ -85,6 +86,7 @@ module.exports = testCase({ test.equal(stompClient.vhost, 'q1.host.net'); test.equal(stompClient.reconnectOpts.retries, 10); test.equal(stompClient.reconnectOpts.delay, 1000); + test.equal(stompClient.clientId, 'testclientid'); test.done(); }, @@ -97,7 +99,8 @@ module.exports = testCase({ pass: 'pw', protocolVersion: '1.1', vhost: 'q1.host.net', - reconnectOpts: { retries: 10, delay: 1000 }}); + reconnectOpts: { retries: 10, delay: 1000 }, + clientId: 'testclientid'}); test.equal(stompClient.user, 'uname'); test.equal(stompClient.pass, 'pw'); @@ -107,6 +110,7 @@ module.exports = testCase({ test.equal(stompClient.vhost, 'q1.host.net'); test.equal(stompClient.reconnectOpts.retries, 10); test.equal(stompClient.reconnectOpts.delay, 1000); + test.equal(stompClient.clientId, 'testclientid'); test.done(); }, From 670738409a6fac52eb425e52b051d676cafe8f0f Mon Sep 17 00:00:00 2001 From: David Brenner Date: Tue, 8 Dec 2020 15:03:28 -0500 Subject: [PATCH 3/4] Update client.test.js Fixed test case clientId parameter value. --- test/client.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/client.test.js b/test/client.test.js index 8954a76..5d20bb8 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -76,7 +76,7 @@ module.exports = testCase({ 'check StompClient construction from paremeters': function(test) { var stompClient = new StompClient( 'test.host.net',1234,'uname','pw', '1.1', 'q1.host.net', - { retries: 10, delay: 1000 }, clientId: 'testclientid'); + { retries: 10, delay: 1000 }, 'testclientid'); test.equal(stompClient.user, 'uname'); test.equal(stompClient.pass, 'pw'); From 31393306bf96bf5b0c9a8a85ddee0f1814209a69 Mon Sep 17 00:00:00 2001 From: David Brenner Date: Tue, 8 Dec 2020 17:29:14 -0500 Subject: [PATCH 4/4] Update client.test.js Added missing tls parameter value in test by parameters. --- test/client.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/client.test.js b/test/client.test.js index 5d20bb8..3cf0053 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -76,7 +76,7 @@ module.exports = testCase({ 'check StompClient construction from paremeters': function(test) { var stompClient = new StompClient( 'test.host.net',1234,'uname','pw', '1.1', 'q1.host.net', - { retries: 10, delay: 1000 }, 'testclientid'); + { retries: 10, delay: 1000 }, true, 'testclientid'); test.equal(stompClient.user, 'uname'); test.equal(stompClient.pass, 'pw');