Skip to content
Snippets Groups Projects
Commit cbf68775 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

#196 - Send ping message every minute to PlayWall

parent 70214a0c
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,10 @@ class ModuleInstance extends InstanceBase {
clearTimeout(this.reconnect_timer)
this.reconnect_timer = null
}
if (this.ping_timer) {
clearTimeout(this.ping_timer)
this.ping_timer = null
}
if (this.ws) {
this.ws.close(1000)
delete this.ws
......@@ -119,11 +123,27 @@ class ModuleInstance extends InstanceBase {
}
}
startPingTrigger() {
if (this.isInitialized) {
if (this.ping_timer) {
clearTimeout(this.ping_timer)
}
this.log('debug', "Start Ping Timer");
this.ping_timer = setInterval(() => {
this.sendToWebSocket('ping', {});
}, 60 * 1000)
}
}
initWebSocket() {
if (this.reconnect_timer) {
clearTimeout(this.reconnect_timer)
this.reconnect_timer = null
}
if (this.ping_timer) {
clearTimeout(this.ping_timer)
this.ping_timer = null
}
if (this.config.host == null || this.config.port == null) {
this.log('debug', `PlayWall host '${this.config.host}' or port '${this.config.port}' is invalid`);
......@@ -148,6 +168,7 @@ class ModuleInstance extends InstanceBase {
this.ws.on('open', () => {
this.updateStatus(InstanceStatus.Ok)
this.log('debug', `Connection opened`)
this.startPingTrigger();
this.sendToWebSocket('project-current', {});
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment