Skip to content

Commit 19c62a4

Browse files
authored
Merge pull request #112 from sjanuary/wss
Support wss in dashboard
2 parents 1eced1a + 572139d commit 19c62a4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

public/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@
9595
<script type="text/javascript" src="js/memChart.js"></script>
9696
<script>
9797
var myurl = location.host;
98-
var client = new WebSocket("ws://" + myurl + "/swiftmetrics-dash","swiftmetrics-dash")
98+
var webSocketProtocol = "ws://"
99+
if(location.protocol === "https:") {
100+
webSocketProtocol = "wss://"
101+
}
102+
var client = new WebSocket(webSocketProtocol + myurl + "/swiftmetrics-dash","swiftmetrics-dash")
99103

100104
client.onmessage = function(message) {
101105
received = JSON.parse(message.data);
102106
topic = received.topic;
103107
payload = JSON.stringify(received.payload);
104108

105-
106-
console.log(topic);
107109
switch (topic) {
108110
case 'cpu':
109111
updateCPUData(payload);

0 commit comments

Comments
 (0)