@@ -489,8 +489,8 @@ class ExcelService extends RpcDispatcher_1.RpcDispatcher {
489
489
getExcelInstances ( callback ) {
490
490
return this . invokeServiceCall ( "getExcelInstances" , null , callback ) ;
491
491
}
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 ) ;
494
494
}
495
495
toObject ( ) {
496
496
return { } ;
@@ -558,7 +558,7 @@ class ExcelApplication extends RpcDispatcher_1.RpcDispatcher {
558
558
constructor ( connectionUuid , logger ) {
559
559
super ( logger ) ;
560
560
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" } ;
562
562
this . loggerName = "ExcelApplication" ;
563
563
this . processExcelEvent = ( data , uuid ) => {
564
564
var eventType = data . event ;
@@ -834,23 +834,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
834
834
exports . ExcelRtd = void 0 ;
835
835
const EventEmitter_1 = __webpack_require__ ( 1 ) ;
836
836
class ExcelRtd extends EventEmitter_1 . EventEmitter {
837
- constructor ( providerName , logger ) {
837
+ constructor ( providerName , logger , heartbeatIntervalInMilliseconds = 10000 ) {
838
838
super ( ) ;
839
+ this . heartbeatIntervalInMilliseconds = heartbeatIntervalInMilliseconds ;
839
840
this . listeners = { } ;
840
841
this . connectedTopics = { } ;
841
842
this . connectedKey = 'connected' ;
842
843
this . disconnectedKey = 'disconnected' ;
843
844
this . loggerName = "ExcelRtd" ;
844
845
this . initialized = false ;
845
846
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
+ }
846
852
this . providerName = providerName ;
847
853
this . logger = logger ;
848
854
logger . debug ( this . loggerName + ": instance created for provider: " + providerName ) ;
849
855
}
850
- static create ( providerName , logger ) {
856
+ static create ( providerName , logger , heartbeatIntervalInMilliseconds = 10000 ) {
851
857
return __awaiter ( this , void 0 , void 0 , function * ( ) {
852
858
logger . debug ( "ExcelRtd: create called to create provider: " + providerName ) ;
853
- const instance = new ExcelRtd ( providerName , logger ) ;
859
+ const instance = new ExcelRtd ( providerName , logger , heartbeatIntervalInMilliseconds ) ;
854
860
yield instance . init ( ) ;
855
861
if ( ! instance . isInitialized ) {
856
862
return undefined ;
@@ -877,6 +883,7 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
877
883
yield fin . InterApplicationBus . subscribe ( { uuid : '*' } , `excelRtd/ping-request/${ this . providerName } ` , this . ping . bind ( this ) ) ;
878
884
yield fin . InterApplicationBus . subscribe ( { uuid : '*' } , `excelRtd/unsubscribed/${ this . providerName } ` , this . onUnsubscribe . bind ( this ) ) ;
879
885
yield this . ping ( ) ;
886
+ this . establishHeartbeat ( ) ;
880
887
this . logger . debug ( this . loggerName + `: initialisation for provider (${ this . providerName } ) finished.` ) ;
881
888
this . initialized = true ;
882
889
} ) ;
@@ -895,6 +902,9 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
895
902
return __awaiter ( this , void 0 , void 0 , function * ( ) {
896
903
if ( ! this . disposed ) {
897
904
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
+ }
898
908
this . clear ( ) ;
899
909
if ( this . provider !== undefined ) {
900
910
try {
@@ -971,17 +981,23 @@ class ExcelRtd extends EventEmitter_1.EventEmitter {
971
981
}
972
982
ping ( topic ) {
973
983
return __awaiter ( this , void 0 , void 0 , function * ( ) {
974
- let pingPath ;
975
984
if ( topic !== undefined ) {
976
- pingPath = `excelRtd/ping/${ this . providerName } /${ topic } ` ;
985
+ this . pingPath = `excelRtd/ping/${ this . providerName } /${ topic } ` ;
977
986
}
978
987
else {
979
- pingPath = `excelRtd/ping/${ this . providerName } ` ;
988
+ this . pingPath = `excelRtd/ping/${ this . providerName } ` ;
980
989
}
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 ) ;
983
992
} ) ;
984
993
}
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
+ }
985
1001
onSubscribe ( topic ) {
986
1002
this . logger . debug ( this . loggerName + `: Subscription for rtdTopic ${ topic } found. Dispatching connected event for rtdTopic.` ) ;
987
1003
this . dispatchEvent ( this . connectedKey , { topic } ) ;
0 commit comments