Skip to content

Commit

Permalink
Merge pull request #5 from koelle25/make-websocket-protocol-aware
Browse files Browse the repository at this point in the history
Make client websocket aware of the used protocol (http/https -> ws/wss)
  • Loading branch information
vzhou842 authored Dec 1, 2019
2 parents 1648bab + 1d190c3 commit 69a84c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/client/networking.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { processGameUpdate } from './state';

const Constants = require('../shared/constants');

const socket = io(`ws://${window.location.host}`, { reconnection: false });
const socketProtocol = (window.location.protocol === 'https') ? 'wss' : 'ws';
const socket = io(`${socketProtocol}://${window.location.host}`, { reconnection: false });
const connectedPromise = new Promise(resolve => {
socket.on('connect', () => {
console.log('Connected to server!');
Expand Down

0 comments on commit 69a84c0

Please sign in to comment.