Parcourir la source

Websocket test should support WSS

bel il y a 11 ans
Parent
commit
ed72d40adf
2 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 1 1
      test/websocket.lua
  2. 2 1
      test/websocket.xhtml

+ 1 - 1
test/websocket.lua

@@ -2,7 +2,7 @@ timerID = "timeout"
 --timerID = "interval"
 
 function trace(text)
-    local f = io.open("R:\\websocket.trace", "a")
+    local f = io.open("websocket.trace", "a")
     f:write(os.date() .. " - " .. text .. "\n")
     f:close()
 end

+ 2 - 1
test/websocket.xhtml

@@ -29,7 +29,8 @@
     }
 
     function load() {
-      connection = new WebSocket("ws://" + window.location.host + "/websocket.lua");
+      var wsproto = (location.protocol === 'https:') ? "wss:" : "ws:";
+      connection = new WebSocket(wsproto + "//" + window.location.host + "/websocket.lua");
       websock_text_field = document.getElementById('websock_text_field');
       hand_min = document.getElementById('hand_min');
       hand_hour = document.getElementById('hand_hour');