detect ws/wss

This commit is contained in:
ok-home
2023-09-28 21:06:31 +07:00
parent 6438c5c77b
commit 8466454a65

View File

@@ -236,7 +236,9 @@
<script> // основной старт скрипта, открыть сокет <script> // основной старт скрипта, открыть сокет
// создать сокет по адресу // создать сокет по адресу
let wsHostStr = "ws://" + document.location.host + document.location.pathname; let protocol = "ws:"
if(document.location.protocol == "https:") protocol = "wss:"
let wsHostStr = protocol + "//" + document.location.host + document.location.pathname;
wsHostStr += (document.location.pathname == '/') ? "ws" : "/ws"; wsHostStr += (document.location.pathname == '/') ? "ws" : "/ws";
var socket = new WebSocket(wsHostStr); var socket = new WebSocket(wsHostStr);
socket.binaryType = "arraybuffer"; socket.binaryType = "arraybuffer";