Skip to content

Commit 7654cce

Browse files
committed
Use secure WS in examples when appropriate
1 parent 85efd08 commit 7654cce

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

examples/echo/assets/script.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const pcConfig = { 'iceServers': [{ 'urls': 'stun:stun.l.google.com:19302' },] };
22
const mediaConstraints = {video: true, audio: true}
33

4-
const ws = new WebSocket(`ws://${window.location.host}/ws`);
4+
const proto = window.location.protocol === "https:" ? "wss:" : "ws:"
5+
const ws = new WebSocket(`${proto}//${window.location.host}/ws`);
56
ws.onopen = _ => start_connection(ws);
67
ws.onclose = event => console.log("WebSocket connection was terminated:", event);
78

examples/save_to_file/assets/script.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const mediaConstraints = {audio: true, video: {
77

88
const button = document.getElementById("button")
99
button.onclick = () => {
10-
const ws = new WebSocket(`ws://${window.location.host}/ws`);
10+
const proto = window.location.protocol === "https:" ? "wss:" : "ws:"
11+
const ws = new WebSocket(`${proto}://${window.location.host}/ws`);
1112
ws.onopen = _ => start_connection(ws);
1213
ws.onclose = event => console.log("WebSocket connection was terminated:", event);
1314

examples/send_from_file/assets/script.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const pcConfig = { 'iceServers': [{ 'urls': 'stun:stun.l.google.com:19302' },] };
22

3-
const ws = new WebSocket(`ws://${window.location.host}/ws`);
3+
4+
const proto = window.location.protocol === "https:" ? "wss:" : "ws:"
5+
const ws = new WebSocket(`${proto}//${window.location.host}/ws`);
46
ws.onopen = _ => start_connection(ws);
57
ws.onclose = event => console.log("WebSocket connection was terminated:", event);
68

0 commit comments

Comments
 (0)