# HG changeset patch # User Edouard Tisserant # Date 1625142794 -7200 # Node ID d22782b9591f3194595371731de7d7901bee8428 # Parent 5f20f391ae31fd879fa874251ba789819f89a767 SVGHMI: Added a way to distinguish watchdog-enabled HMI from multi-client HMI in URL. diff -r 5f20f391ae31 -r d22782b9591f svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Wed Jun 30 15:51:59 2021 +0200 +++ b/svghmi/gen_index_xhtml.xslt Thu Jul 01 14:33:14 2021 +0200 @@ -7556,7 +7556,19 @@ // Open WebSocket to relative "/ws" address - var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws')); + + + var ws_url = + + window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') + + + '?mode=' + (window.location.hash == "#watchdog" + + ? "watchdog" + + : "multiclient"); + + var ws = new WebSocket(ws_url); ws.binaryType = 'arraybuffer'; diff -r 5f20f391ae31 -r d22782b9591f svghmi/svghmi.js --- a/svghmi/svghmi.js Wed Jun 30 15:51:59 2021 +0200 +++ b/svghmi/svghmi.js Thu Jul 01 14:33:14 2021 +0200 @@ -30,7 +30,13 @@ }; // Open WebSocket to relative "/ws" address -var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws')); + +var ws_url = + window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') + + '?mode=' + (window.location.hash == "#watchdog" + ? "watchdog" + : "multiclient"); +var ws = new WebSocket(ws_url); ws.binaryType = 'arraybuffer'; const dvgetters = { diff -r 5f20f391ae31 -r d22782b9591f svghmi/svghmi_server.py --- a/svghmi/svghmi_server.py Wed Jun 30 15:51:59 2021 +0200 +++ b/svghmi/svghmi_server.py Thu Jul 01 14:33:14 2021 +0200 @@ -120,6 +120,10 @@ self._hmi_session = None WebSocketServerProtocol.__init__(self, *args, **kwargs) + def onConnect(self, request): + self.has_watchdog = request.params.get("mode", [None])[0] == "watchdog" + return WebSocketServerProtocol.onConnect(self, request) + def onOpen(self): assert(self._hmi_session is None) self._hmi_session = HMISession(self)