SVGHMI: Added a way to distinguish watchdog-enabled HMI from multi-client HMI in URL.
--- 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 @@
</xsl:text>
<xsl:text>// Open WebSocket to relative "/ws" address
</xsl:text>
- <xsl:text>var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws'));
+ <xsl:text>
+</xsl:text>
+ <xsl:text>var ws_url =
+</xsl:text>
+ <xsl:text> window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws')
+</xsl:text>
+ <xsl:text> + '?mode=' + (window.location.hash == "#watchdog"
+</xsl:text>
+ <xsl:text> ? "watchdog"
+</xsl:text>
+ <xsl:text> : "multiclient");
+</xsl:text>
+ <xsl:text>var ws = new WebSocket(ws_url);
</xsl:text>
<xsl:text>ws.binaryType = 'arraybuffer';
</xsl:text>
--- 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 = {
--- 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)