From 39e12465aa30c79799e9c443f0fa393a07019cef Mon Sep 17 00:00:00 2001 From: RblSb Date: Sun, 8 Mar 2020 09:43:48 +0300 Subject: Use wss protocol on https page --- src/client/Main.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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); -- cgit v1.2.3