Use correct websocket protocol

Based on window location the correct websocket protocol can be used.
pull/93/head
Ethan Apodaca 4 years ago
parent 642f487a01
commit 40c6603226
No known key found for this signature in database
GPG Key ID: 37DAA8FA806E4FE1

@ -117,8 +117,9 @@
} }
function getWebsocketConnection(onOpen,onMessage){ function getWebsocketConnection(onOpen,onMessage){
const wsProto = window.location.protocol.startsWith('https') ? 'wss://' : 'ws://';
// Create WebSocket connection. // Create WebSocket connection.
const socket = new WebSocket('ws://'+window.location.host+'/ws'); const socket = new WebSocket(wsProto+window.location.host+'/ws');
socket.addEventListener('open', onOpen); socket.addEventListener('open', onOpen);

Loading…
Cancel
Save