Skip to content

Commit

Permalink
Fix for readonly caption and heartbeat timeout for RTD (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilVogt committed May 11, 2021
1 parent c1595b9 commit 5e314f7
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 3,747 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,2 +1,3 @@
node_modules
.idea
.idea
package-lock.json
38 changes: 27 additions & 11 deletions client/fin.desktop.Excel.js
Expand Up @@ -489,8 +489,8 @@ class ExcelService extends RpcDispatcher_1.RpcDispatcher {
getExcelInstances(callback) {
return this.invokeServiceCall("getExcelInstances", null, callback);
}
createRtd(providerName) {
return ExcelRtd_1.ExcelRtd.create(providerName, this.logger);
createRtd(providerName, heartbeatIntervalInMilliseconds = 10000) {
return ExcelRtd_1.ExcelRtd.create(providerName, this.logger, heartbeatIntervalInMilliseconds);
}
toObject() {
return {};
Expand Down Expand Up @@ -558,7 +558,7 @@ class ExcelApplication extends RpcDispatcher_1.RpcDispatcher {
constructor(connectionUuid, logger) {
super(logger);
this.workbooks = {};
this.version = { clientVersion: "4.0.4", buildVersion: "4.0.4.0" };
this.version = { clientVersion: "4.0.5", buildVersion: "4.0.5.0" };
this.loggerName = "ExcelApplication";
this.processExcelEvent = (data, uuid) => {
var eventType = data.event;
Expand Down Expand Up @@ -834,23 +834,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.ExcelRtd = void 0;
const EventEmitter_1 = __webpack_require__(1);
class ExcelRtd extends EventEmitter_1.EventEmitter {
constructor(providerName, logger) {
constructor(providerName, logger, heartbeatIntervalInMilliseconds = 10000) {
super();
this.heartbeatIntervalInMilliseconds = heartbeatIntervalInMilliseconds;
this.listeners = {};
this.connectedTopics = {};
this.connectedKey = 'connected';
this.disconnectedKey = 'disconnected';
this.loggerName = "ExcelRtd";
this.initialized = false;
this.disposed = false;
var minimumDefaultHeartbeat = 10000;
if (this.heartbeatIntervalInMilliseconds < minimumDefaultHeartbeat) {
logger.warn(`heartbeatIntervalInMilliseconds cannot be less than ${minimumDefaultHeartbeat}. Setting heartbeatIntervalInMilliseconds to ${minimumDefaultHeartbeat}.`);
this.heartbeatIntervalInMilliseconds = minimumDefaultHeartbeat;
}
this.providerName = providerName;
this.logger = logger;
logger.debug(this.loggerName + ": instance created for provider: " + providerName);
}
static create(providerName, logger) {
static create(providerName, logger, heartbeatIntervalInMilliseconds = 10000) {
return __awaiter(this, void 0, void 0, function* () {
logger.debug("ExcelRtd: create called to create provider: " + providerName);
const instance = new ExcelRtd(providerName, logger);
const instance = new ExcelRtd(providerName, logger, heartbeatIntervalInMilliseconds);
yield instance.init();
if (!instance.isInitialized) {
return undefined;
Expand All @@ -877,6 +883,7 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
yield fin.InterApplicationBus.subscribe({ uuid: '*' }, `excelRtd/ping-request/${this.providerName}`, this.ping.bind(this));
yield fin.InterApplicationBus.subscribe({ uuid: '*' }, `excelRtd/unsubscribed/${this.providerName}`, this.onUnsubscribe.bind(this));
yield this.ping();
this.establishHeartbeat();
this.logger.debug(this.loggerName + `: initialisation for provider (${this.providerName}) finished.`);
this.initialized = true;
});
Expand All @@ -895,6 +902,9 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
return __awaiter(this, void 0, void 0, function* () {
if (!this.disposed) {
this.logger.debug(this.loggerName + `: dispose called. Will send message to clear values for this provider (${this.providerName}).`);
if (this.heartbeatToken) {
clearInterval(this.heartbeatToken);
}
this.clear();
if (this.provider !== undefined) {
try {
Expand Down Expand Up @@ -971,17 +981,23 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
}
ping(topic) {
return __awaiter(this, void 0, void 0, function* () {
let pingPath;
if (topic !== undefined) {
pingPath = `excelRtd/ping/${this.providerName}/${topic}`;
this.pingPath = `excelRtd/ping/${this.providerName}/${topic}`;
}
else {
pingPath = `excelRtd/ping/${this.providerName}`;
this.pingPath = `excelRtd/ping/${this.providerName}`;
}
this.logger.debug(this.loggerName + `: Publishing ping message for this provider (${this.providerName}) to excel on topic: ${pingPath}.`);
yield fin.InterApplicationBus.publish(`${pingPath}`, true);
this.logger.debug(this.loggerName + `: Publishing ping message for this provider (${this.providerName}) to excel on topic: ${this.pingPath}.`);
yield fin.InterApplicationBus.publish(`${this.pingPath}`, true);
});
}
establishHeartbeat() {
this.heartbeatPath = `excelRtd/heartbeat/${this.providerName}`;
this.heartbeatToken = setInterval(() => {
this.logger.debug(`Heartbeating for ${this.heartbeatPath}.`);
fin.InterApplicationBus.publish(`${this.heartbeatPath}`, this.heartbeatIntervalInMilliseconds);
}, this.heartbeatIntervalInMilliseconds);
}
onSubscribe(topic) {
this.logger.debug(this.loggerName + `: Subscription for rtdTopic ${topic} found. Dispatching connected event for rtdTopic.`);
this.dispatchEvent(this.connectedKey, { topic });
Expand Down
2 changes: 1 addition & 1 deletion client/src/ExcelApi.d.ts
Expand Up @@ -30,6 +30,6 @@ export declare class ExcelService extends RpcDispatcher {
install(callback?: Function): Promise<any>;
getInstallationStatus(callback?: Function): Promise<any>;
getExcelInstances(callback?: Function): Promise<any>;
createRtd(providerName: string): Promise<ExcelRtd>;
createRtd(providerName: string, heartbeatIntervalInMilliseconds?: number): Promise<ExcelRtd>;
toObject(): any;
}
4 changes: 2 additions & 2 deletions client/src/ExcelApi.js

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

9 changes: 7 additions & 2 deletions client/src/ExcelRtd.d.ts
@@ -1,20 +1,24 @@
import { EventEmitter } from './EventEmitter';
import { ILog } from './ILog';
export declare class ExcelRtd extends EventEmitter {
private heartbeatIntervalInMilliseconds;
providerName: string;
provider: any;
logger: ILog;
listeners: {
[eventType: string]: Function[];
};
pingPath: string;
heartbeatPath: string;
connectedTopics: {};
connectedKey: string;
disconnectedKey: string;
loggerName: string;
private initialized;
private disposed;
static create(providerName: any, logger: ILog): Promise<ExcelRtd>;
constructor(providerName: any, logger: ILog);
heartbeatToken: number;
static create(providerName: any, logger: ILog, heartbeatIntervalInMilliseconds?: number): Promise<ExcelRtd>;
constructor(providerName: any, logger: ILog, heartbeatIntervalInMilliseconds?: number);
init(): Promise<void>;
get isDisposed(): boolean;
get isInitialized(): boolean;
Expand All @@ -25,6 +29,7 @@ export declare class ExcelRtd extends EventEmitter {
dispatchEvent(typeArg: string, data?: any): boolean;
toObject(): this;
private ping;
private establishHeartbeat;
private onSubscribe;
private onUnsubscribe;
private clear;
Expand Down
32 changes: 24 additions & 8 deletions client/src/ExcelRtd.js

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

10 changes: 5 additions & 5 deletions demo/app.json
Expand Up @@ -2,9 +2,9 @@
"licenseKey": "64605fac-add3-48a0-8710-64b38e96a2dd",
"startup_app": {
"name": "Excel-API-Example",
"url": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/index.html",
"url": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/index.html",
"uuid": "excel-api-example",
"applicationIcon": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/openfin-excel.ico",
"applicationIcon": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/openfin-excel.ico",
"autoShow": true,
"defaultWidth": 760,
"defaultHeight": 704,
Expand All @@ -21,17 +21,17 @@
"arguments": "",
"version": "14.78.48.16"
},
"splashScreenImage": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/splash_excel.png",
"splashScreenImage": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/splash_excel.png",
"shortcut": {
"company": "OpenFin",
"description": "excel-api-example",
"icon": "https://cdn.openfin.co/release/exceljs/4.0.4/demo/openfin-excel.ico",
"icon": "https://cdn.openfin.co/release/exceljs/4.0.5/demo/openfin-excel.ico",
"name": "excel-api-example"
},
"services": [
{
"name": "excel",
"manifestUrl": "https://cdn.openfin.co/release/exceljs/4.0.4/provider/app.json"
"manifestUrl": "https://cdn.openfin.co/release/exceljs/4.0.5/provider/app.json"
}
]
}

0 comments on commit 5e314f7

Please sign in to comment.