Skip to content

Commit

Permalink
Dynamically detect ws or wss
Browse files Browse the repository at this point in the history
  • Loading branch information
RedTachyon committed Feb 29, 2024
1 parent bb5af0f commit d3faa7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cogment_lab/humans/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ <h1>RL Env Interface</h1>

document.getElementById('start-button').addEventListener('click', function() {
if (!isConnected) {
socket = new WebSocket("wss://" + location.host + "/ws");
const wsProtocol = location.protocol === 'https:' ? 'wss://' : 'ws://';

socket = new WebSocket(wsProtocol + location.host + "/ws");
socket.onmessage = function(event) {
let image = document.getElementById('env-render');
let json = JSON.parse(event.data);
Expand Down

0 comments on commit d3faa7c

Please sign in to comment.