Support SSL web sockets

This should make Ooui work with HTTPS

Fixes #51
This commit is contained in:
Frank A. Krueger 2018-02-01 14:23:42 -08:00
parent 03f9ed2d91
commit 0ff69fd3b7
1 changed files with 5 additions and 1 deletions

View File

@ -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");