From 69f8215674be9c15ffd4cde7b453f9f0aeebcf1c Mon Sep 17 00:00:00 2001 From: Chinmay Pendharkar <553140+notthetup@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:19:22 +0800 Subject: [PATCH] fix(fjage.js): fixing addConnListener function in fjage.js --- docs/jsdoc/index.html | 102 ++++++++++++++-------------- gateways/js/dist/esm/fjage.js | 7 +- gateways/js/dist/fjage.js | 7 +- gateways/js/package-lock.json | 4 +- gateways/js/package.json | 2 +- gateways/js/src/fjage.js | 1 + gateways/js/test/spec/fjage.spec.js | 16 +++++ 7 files changed, 79 insertions(+), 60 deletions(-) diff --git a/docs/jsdoc/index.html b/docs/jsdoc/index.html index 701c4b36..da6abe5a 100644 --- a/docs/jsdoc/index.html +++ b/docs/jsdoc/index.html @@ -2,7 +2,7 @@
-1.11.0
1.11.1
const ParameterReq = MessageClass('org.arl.fjage.param.ParameterReq');
-let pReq = new ParameterReq()
+ const ParameterReq = MessageClass('org.arl.fjage.param.ParameterReq');
+let pReq = new ParameterReq()
diff --git a/gateways/js/dist/esm/fjage.js b/gateways/js/dist/esm/fjage.js
index 7dccfadb..5ae51ad1 100644
--- a/gateways/js/dist/esm/fjage.js
+++ b/gateways/js/dist/esm/fjage.js
@@ -1,4 +1,4 @@
-/* fjage.js v1.11.0 */
+/* fjage.js v1.11.1 */
const isBrowser =
typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -75,7 +75,7 @@ class TCPconnector {
}
}else {
this._sockSetup(host, port);
- }
+ }
}
_sockSetup(host, port){
@@ -162,7 +162,7 @@ class TCPconnector {
* @ignore
* @param {string} s - incoming message string
*/
-
+
/**
* Add listener for connection events
* @param {function} listener - a listener callback that is called when the connection is opened/closed
@@ -842,6 +842,7 @@ class Gateway {
this.connector.write('{"alive": true}');
this._update_watch();
}
+ this._sendEvent('conn', state);
});
return conn;
}
diff --git a/gateways/js/dist/fjage.js b/gateways/js/dist/fjage.js
index cb4a283d..50300458 100644
--- a/gateways/js/dist/fjage.js
+++ b/gateways/js/dist/fjage.js
@@ -1,4 +1,4 @@
-/* fjage.js v1.11.0 */
+/* fjage.js v1.11.1 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -81,7 +81,7 @@
}
}else {
this._sockSetup(host, port);
- }
+ }
}
_sockSetup(host, port){
@@ -168,7 +168,7 @@
* @ignore
* @param {string} s - incoming message string
*/
-
+
/**
* Add listener for connection events
* @param {function} listener - a listener callback that is called when the connection is opened/closed
@@ -848,6 +848,7 @@
this.connector.write('{"alive": true}');
this._update_watch();
}
+ this._sendEvent('conn', state);
});
return conn;
}
diff --git a/gateways/js/package-lock.json b/gateways/js/package-lock.json
index f8609874..76eac642 100644
--- a/gateways/js/package-lock.json
+++ b/gateways/js/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "fjage",
- "version": "1.11.0",
+ "version": "1.11.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "fjage",
- "version": "1.11.0",
+ "version": "1.11.1",
"license": "BSD-2-Clause",
"dependencies": {
"browser-or-node": "^2.1.1"
diff --git a/gateways/js/package.json b/gateways/js/package.json
index bb0e0921..5afaa937 100644
--- a/gateways/js/package.json
+++ b/gateways/js/package.json
@@ -1,6 +1,6 @@
{
"name": "fjage",
- "version": "1.11.0",
+ "version": "1.11.1",
"description": "JS Gateway for fjåge",
"main": "./dist/cjs/fjage.cjs",
"exports": {
diff --git a/gateways/js/src/fjage.js b/gateways/js/src/fjage.js
index 3d97bfb3..c8b308a6 100644
--- a/gateways/js/src/fjage.js
+++ b/gateways/js/src/fjage.js
@@ -488,6 +488,7 @@ export class Gateway {
this.connector.write('{"alive": true}');
this._update_watch();
}
+ this._sendEvent('conn', state);
});
return conn;
}
diff --git a/gateways/js/test/spec/fjage.spec.js b/gateways/js/test/spec/fjage.spec.js
index 09518973..aa8996d1 100644
--- a/gateways/js/test/spec/fjage.spec.js
+++ b/gateways/js/test/spec/fjage.spec.js
@@ -251,6 +251,22 @@ describe('A Gateway', function () {
}
expect(rxed).not.toContain(false);
});
+
+ it('should generate trigger connListener when the underlying transport is disconnected/reconnected', async function() {
+ const gw = new Gateway(gwOpts);
+ let spy = jasmine.createSpy('connListener');
+ gw.addConnListener(spy);
+ await delay(300);
+ spy.calls.reset();
+ gw.connector._reconnectTime = 300;
+ gw.connector.sock.close();
+ await delay(100);
+ expect(spy).toHaveBeenCalledWith(false);
+ spy.calls.reset();
+ await delay(500);
+ expect(spy).toHaveBeenCalledWith(true);
+ gw.connector._reconnectTime = 5000;
+ });
});
describe('An AgentID', function () {