From 0ff69fd3b713fba09881dc0a0317f3281990a5c7 Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Thu, 1 Feb 2018 14:23:42 -0800 Subject: [PATCH] Support SSL web sockets This should make Ooui work with HTTPS Fixes #51 --- Ooui/Client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Ooui/Client.js b/Ooui/Client.js index f77d6e1..094aa1a 100644 --- a/Ooui/Client.js +++ b/Ooui/Client.js @@ -43,7 +43,11 @@ function ooui (rootElementPath) { var wsArgs = (rootElementPath.indexOf("?") >= 0 ? "&" : "?") + "w=" + initialSize.width + "&h=" + initialSize.height; - socket = new WebSocket ("ws://" + document.location.host + rootElementPath + wsArgs, "ooui"); + var proto = "ws"; + if (location.protocol == "https:") { + proto = "wss"; + } + socket = new WebSocket (proto + "://" + document.location.host + rootElementPath + wsArgs, "ooui"); socket.addEventListener ("open", function (event) { console.log ("Web socket opened");