diff --git a/examples/websocket/index.html b/examples/websocket/index.html index 74818a88..1a95aa80 100644 --- a/examples/websocket/index.html +++ b/examples/websocket/index.html @@ -21,7 +21,10 @@

WebSocket demo

-

Proxy ws://localhost:3000 to ws://ws.ifelse.io

+

+ Proxy ws://localhost:3000 ➡ + ws://ws.ifelse.io +

@@ -48,6 +51,7 @@

WebSocket demo

// elements const configuration = document.getElementById('configuration'); const location = document.getElementById('location'); + const codeblockWsLocation = document.getElementById('codeblock-ws-location'); const connectBtn = document.getElementById('connectBtn'); const disconnectBtn = document.getElementById('disconnectBtn'); const messaging = document.getElementById('messaging'); @@ -55,6 +59,13 @@

WebSocket demo

const sendBtn = document.getElementById('sendBtn'); const logger = document.getElementById('logger'); + const documentUrl = new URL(document.location); + const wsProtocol = documentUrl.protocol.includes('https') ? 'wss:' : 'ws:'; + const wsPort = documentUrl.port ? `:${documentUrl.port}` : ''; + const locationValue = `${wsProtocol}//${documentUrl.host}${wsPort}`; + location.value = locationValue; + codeblockWsLocation.innerText = locationValue; + // ws let socket;