Skip to content

Commit

Permalink
fix(fjage.js): fixing addConnListener function in fjage.js
Browse files Browse the repository at this point in the history
  • Loading branch information
notthetup committed Dec 11, 2023
1 parent 7af81a6 commit 69f8215
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 60 deletions.
102 changes: 51 additions & 51 deletions docs/jsdoc/index.html

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions gateways/js/dist/esm/fjage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* fjage.js v1.11.0 */
/* fjage.js v1.11.1 */

const isBrowser =
typeof window !== "undefined" && typeof window.document !== "undefined";
Expand Down Expand Up @@ -75,7 +75,7 @@ class TCPconnector {
}
}else {
this._sockSetup(host, port);
}
}
}

_sockSetup(host, port){
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -842,6 +842,7 @@ class Gateway {
this.connector.write('{"alive": true}');
this._update_watch();
}
this._sendEvent('conn', state);
});
return conn;
}
Expand Down
7 changes: 4 additions & 3 deletions gateways/js/dist/fjage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gateways/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gateways/js/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
1 change: 1 addition & 0 deletions gateways/js/src/fjage.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ export class Gateway {
this.connector.write('{"alive": true}');
this._update_watch();
}
this._sendEvent('conn', state);
});
return conn;
}
Expand Down
16 changes: 16 additions & 0 deletions gateways/js/test/spec/fjage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 69f8215

Please sign in to comment.