Skip to content

Commit 5e314f7

Browse files
authored
Fix for readonly caption and heartbeat timeout for RTD (#60)
1 parent c1595b9 commit 5e314f7

13 files changed

+75
-3747
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
.idea
2+
.idea
3+
package-lock.json

Diff for: client/fin.desktop.Excel.js

+27-11
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ class ExcelService extends RpcDispatcher_1.RpcDispatcher {
489489
getExcelInstances(callback) {
490490
return this.invokeServiceCall("getExcelInstances", null, callback);
491491
}
492-
createRtd(providerName) {
493-
return ExcelRtd_1.ExcelRtd.create(providerName, this.logger);
492+
createRtd(providerName, heartbeatIntervalInMilliseconds = 10000) {
493+
return ExcelRtd_1.ExcelRtd.create(providerName, this.logger, heartbeatIntervalInMilliseconds);
494494
}
495495
toObject() {
496496
return {};
@@ -558,7 +558,7 @@ class ExcelApplication extends RpcDispatcher_1.RpcDispatcher {
558558
constructor(connectionUuid, logger) {
559559
super(logger);
560560
this.workbooks = {};
561-
this.version = { clientVersion: "4.0.4", buildVersion: "4.0.4.0" };
561+
this.version = { clientVersion: "4.0.5", buildVersion: "4.0.5.0" };
562562
this.loggerName = "ExcelApplication";
563563
this.processExcelEvent = (data, uuid) => {
564564
var eventType = data.event;
@@ -834,23 +834,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
834834
exports.ExcelRtd = void 0;
835835
const EventEmitter_1 = __webpack_require__(1);
836836
class ExcelRtd extends EventEmitter_1.EventEmitter {
837-
constructor(providerName, logger) {
837+
constructor(providerName, logger, heartbeatIntervalInMilliseconds = 10000) {
838838
super();
839+
this.heartbeatIntervalInMilliseconds = heartbeatIntervalInMilliseconds;
839840
this.listeners = {};
840841
this.connectedTopics = {};
841842
this.connectedKey = 'connected';
842843
this.disconnectedKey = 'disconnected';
843844
this.loggerName = "ExcelRtd";
844845
this.initialized = false;
845846
this.disposed = false;
847+
var minimumDefaultHeartbeat = 10000;
848+
if (this.heartbeatIntervalInMilliseconds < minimumDefaultHeartbeat) {
849+
logger.warn(`heartbeatIntervalInMilliseconds cannot be less than ${minimumDefaultHeartbeat}. Setting heartbeatIntervalInMilliseconds to ${minimumDefaultHeartbeat}.`);
850+
this.heartbeatIntervalInMilliseconds = minimumDefaultHeartbeat;
851+
}
846852
this.providerName = providerName;
847853
this.logger = logger;
848854
logger.debug(this.loggerName + ": instance created for provider: " + providerName);
849855
}
850-
static create(providerName, logger) {
856+
static create(providerName, logger, heartbeatIntervalInMilliseconds = 10000) {
851857
return __awaiter(this, void 0, void 0, function* () {
852858
logger.debug("ExcelRtd: create called to create provider: " + providerName);
853-
const instance = new ExcelRtd(providerName, logger);
859+
const instance = new ExcelRtd(providerName, logger, heartbeatIntervalInMilliseconds);
854860
yield instance.init();
855861
if (!instance.isInitialized) {
856862
return undefined;
@@ -877,6 +883,7 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
877883
yield fin.InterApplicationBus.subscribe({ uuid: '*' }, `excelRtd/ping-request/${this.providerName}`, this.ping.bind(this));
878884
yield fin.InterApplicationBus.subscribe({ uuid: '*' }, `excelRtd/unsubscribed/${this.providerName}`, this.onUnsubscribe.bind(this));
879885
yield this.ping();
886+
this.establishHeartbeat();
880887
this.logger.debug(this.loggerName + `: initialisation for provider (${this.providerName}) finished.`);
881888
this.initialized = true;
882889
});
@@ -895,6 +902,9 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
895902
return __awaiter(this, void 0, void 0, function* () {
896903
if (!this.disposed) {
897904
this.logger.debug(this.loggerName + `: dispose called. Will send message to clear values for this provider (${this.providerName}).`);
905+
if (this.heartbeatToken) {
906+
clearInterval(this.heartbeatToken);
907+
}
898908
this.clear();
899909
if (this.provider !== undefined) {
900910
try {
@@ -971,17 +981,23 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
971981
}
972982
ping(topic) {
973983
return __awaiter(this, void 0, void 0, function* () {
974-
let pingPath;
975984
if (topic !== undefined) {
976-
pingPath = `excelRtd/ping/${this.providerName}/${topic}`;
985+
this.pingPath = `excelRtd/ping/${this.providerName}/${topic}`;
977986
}
978987
else {
979-
pingPath = `excelRtd/ping/${this.providerName}`;
988+
this.pingPath = `excelRtd/ping/${this.providerName}`;
980989
}
981-
this.logger.debug(this.loggerName + `: Publishing ping message for this provider (${this.providerName}) to excel on topic: ${pingPath}.`);
982-
yield fin.InterApplicationBus.publish(`${pingPath}`, true);
990+
this.logger.debug(this.loggerName + `: Publishing ping message for this provider (${this.providerName}) to excel on topic: ${this.pingPath}.`);
991+
yield fin.InterApplicationBus.publish(`${this.pingPath}`, true);
983992
});
984993
}
994+
establishHeartbeat() {
995+
this.heartbeatPath = `excelRtd/heartbeat/${this.providerName}`;
996+
this.heartbeatToken = setInterval(() => {
997+
this.logger.debug(`Heartbeating for ${this.heartbeatPath}.`);
998+
fin.InterApplicationBus.publish(`${this.heartbeatPath}`, this.heartbeatIntervalInMilliseconds);
999+
}, this.heartbeatIntervalInMilliseconds);
1000+
}
9851001
onSubscribe(topic) {
9861002
this.logger.debug(this.loggerName + `: Subscription for rtdTopic ${topic} found. Dispatching connected event for rtdTopic.`);
9871003
this.dispatchEvent(this.connectedKey, { topic });

Diff for: client/src/ExcelApi.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ export declare class ExcelService extends RpcDispatcher {
3030
install(callback?: Function): Promise<any>;
3131
getInstallationStatus(callback?: Function): Promise<any>;
3232
getExcelInstances(callback?: Function): Promise<any>;
33-
createRtd(providerName: string): Promise<ExcelRtd>;
33+
createRtd(providerName: string, heartbeatIntervalInMilliseconds?: number): Promise<ExcelRtd>;
3434
toObject(): any;
3535
}

Diff for: client/src/ExcelApi.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: client/src/ExcelRtd.d.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import { EventEmitter } from './EventEmitter';
22
import { ILog } from './ILog';
33
export declare class ExcelRtd extends EventEmitter {
4+
private heartbeatIntervalInMilliseconds;
45
providerName: string;
56
provider: any;
67
logger: ILog;
78
listeners: {
89
[eventType: string]: Function[];
910
};
11+
pingPath: string;
12+
heartbeatPath: string;
1013
connectedTopics: {};
1114
connectedKey: string;
1215
disconnectedKey: string;
1316
loggerName: string;
1417
private initialized;
1518
private disposed;
16-
static create(providerName: any, logger: ILog): Promise<ExcelRtd>;
17-
constructor(providerName: any, logger: ILog);
19+
heartbeatToken: number;
20+
static create(providerName: any, logger: ILog, heartbeatIntervalInMilliseconds?: number): Promise<ExcelRtd>;
21+
constructor(providerName: any, logger: ILog, heartbeatIntervalInMilliseconds?: number);
1822
init(): Promise<void>;
1923
get isDisposed(): boolean;
2024
get isInitialized(): boolean;
@@ -25,6 +29,7 @@ export declare class ExcelRtd extends EventEmitter {
2529
dispatchEvent(typeArg: string, data?: any): boolean;
2630
toObject(): this;
2731
private ping;
32+
private establishHeartbeat;
2833
private onSubscribe;
2934
private onUnsubscribe;
3035
private clear;

Diff for: client/src/ExcelRtd.js

+24-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: demo/app.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"licenseKey": "64605fac-add3-48a0-8710-64b38e96a2dd",
33
"startup_app": {
44
"name": "Excel-API-Example",
5-
"url": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/index.html",
5+
"url": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/index.html",
66
"uuid": "excel-api-example",
7-
"applicationIcon": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/openfin-excel.ico",
7+
"applicationIcon": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/openfin-excel.ico",
88
"autoShow": true,
99
"defaultWidth": 760,
1010
"defaultHeight": 704,
@@ -21,17 +21,17 @@
2121
"arguments": "",
2222
"version": "14.78.48.16"
2323
},
24-
"splashScreenImage": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/splash_excel.png",
24+
"splashScreenImage": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/splash_excel.png",
2525
"shortcut": {
2626
"company": "OpenFin",
2727
"description": "excel-api-example",
28-
"icon": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/openfin-excel.ico",
28+
"icon": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/openfin-excel.ico",
2929
"name": "excel-api-example"
3030
},
3131
"services": [
3232
{
3333
"name": "excel",
34-
"manifestUrl": "https://cdn.openfin.co/release/exceljs/4.0.4/provider/app.json"
34+
"manifestUrl": "https://cdn.openfin.co/release/exceljs/4.0.5/provider/app.json"
3535
}
3636
]
3737
}

0 commit comments

Comments
 (0)