aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-03-08 09:43:48 +0300
committerRblSb <msrblsb@gmail.com>2020-03-08 09:43:48 +0300
commit39e12465aa30c79799e9c443f0fa393a07019cef (patch)
tree678ab49f5766ed24d1211b0aa9394f4291fbffd4
parenta156726fd7962dd51886b8ecfb0cfd54ef2343ae (diff)
Use wss protocol on https page
-rw-r--r--res/client.js8
-rw-r--r--src/client/Main.hx4
2 files changed, 9 insertions, 3 deletions
diff --git a/res/client.js b/res/client.js
index 240d382..932f180 100644
--- a/res/client.js
+++ b/res/client.js
@@ -806,7 +806,11 @@ client_Main.prototype = {
}
,openWebSocket: function(host,port) {
var _gthis = this;
- this.ws = new WebSocket("ws://" + host + ":" + port);
+ var protocol = "ws:";
+ if(window.location.protocol == "https:") {
+ protocol = "wss:";
+ }
+ this.ws = new WebSocket("" + protocol + "//" + host + ":" + port);
this.ws.onmessage = $bind(this,this.onMessage);
this.ws.onopen = function() {
_gthis.serverMessage(1);
@@ -973,7 +977,7 @@ client_Main.prototype = {
var data = JSON.parse(e.data);
var t = data.type;
var t1 = t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null);
- haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 258, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]});
+ haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 260, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]});
switch(data.type) {
case "AddVideo":
this.player.addVideoItem(data.addVideo.item,data.addVideo.atEnd);
diff --git a/src/client/Main.hx b/src/client/Main.hx
index 918a81a..8edeb8f 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -67,7 +67,9 @@ class Main {
}
function openWebSocket(host:String, port:String):Void {
- ws = new WebSocket('ws://$host:$port');
+ var protocol = "ws:";
+ if (Browser.location.protocol == "https:") protocol = "wss:";
+ ws = new WebSocket('$protocol//$host:$port');
ws.onmessage = onMessage;
ws.onopen = () -> {
serverMessage(1);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage