diff --git a/public/js/app.js b/public/js/app.js index 423343a..77eee08 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -7,10 +7,13 @@ class App { /** * Create a new App object. * @param {string} serverUrl - The URL of the server. + * @param {string} socketUrl - The URL of the socket server. (Optional, defaults to the server URL.) */ - constructor(serverUrl) { + constructor(serverUrl, socketUrl) { this.serverUrl = serverUrl; this.session.serverUrl = serverUrl; + + this.socketUrl = socketUrl || serverUrl; } /** diff --git a/public/js/game.js b/public/js/game.js index 89bd98c..2c0c4d9 100644 --- a/public/js/game.js +++ b/public/js/game.js @@ -9,10 +9,10 @@ class GameNetwork { /** * Create a game network. - * @param {string} serverUrl - The server URL. + * @param {string} socketUrl - The socket URL. */ - constructor(serverUrl) { - this.socket = io(serverUrl, { + constructor(socketUrl) { + this.socket = io(socketUrl, { withCredentials: true, }); } diff --git a/views/pages/game.ejs b/views/pages/game.ejs index 6642f3e..93d068e 100644 --- a/views/pages/game.ejs +++ b/views/pages/game.ejs @@ -79,7 +79,7 @@ const gameUI = new GameUI("/img/game/wood-texture.jpg"); // Create a new game network instance - const gameNetwork = new GameNetwork(app.serverUrl); + const gameNetwork = new GameNetwork(app.socketUrl); // Add disconnect event listener const disconnectListener = () => {