Added websocket url to config file

This commit is contained in:
Per Qvarforth 2022-02-27 17:13:07 +00:00
parent 08878eab81
commit d8e75e5b49
2 changed files with 7 additions and 3 deletions

View File

@ -23,6 +23,10 @@ leaflet_raster_tile_satellite="" ;; Examples: "HERE.satelliteDay"
coverage_only_moving_senders="0" coverage_only_moving_senders="0"
coverage_percentile="95" coverage_percentile="95"
;; Url to the websocket server, if you use https you need to set this
;; If nothing is set we will try the url: ws://current-url:9000/ws
;websocket_url="wss://ws.my-domain.com"
[database] [database]

View File

@ -146,9 +146,9 @@ $REQUEST_PROTOCOL = $isSecure ? 'https' : 'http';
options['host'] = "<?php echo $_SERVER['HTTP_HOST']; ?>"; options['host'] = "<?php echo $_SERVER['HTTP_HOST']; ?>";
var supportsWebSockets = 'WebSocket' in window || 'MozWebSocket' in window; var supportsWebSockets = 'WebSocket' in window || 'MozWebSocket' in window;
if (supportsWebSockets) { if (supportsWebSockets) {
<?php if ($REQUEST_PROTOCOL == 'https') : ?> <?php if (getWebsiteConfig('websocket_url') != null) : ?>
var wsServerUrl = 'wss://<?php echo $_SERVER['HTTP_HOST']; ?>:9000/ws'; var wsServerUrl = "<?php echo getWebsiteConfig('websocket_url'); ?>";
<?php else : ?> <?php else : ?>
var wsServerUrl = 'ws://<?php echo $_SERVER['HTTP_HOST']; ?>:9000/ws'; var wsServerUrl = 'ws://<?php echo $_SERVER['HTTP_HOST']; ?>:9000/ws';
<?php endif; ?> <?php endif; ?>