diff --git a/docker-compose.yml b/docker-compose.yml index 974225f..2b73485 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,9 @@ services: container_name: "web" image: "node" ports: - - "6969:80" - - "8080:8080" + - "6969:6969" + - "4242:4242" volumes: - ".:/app" + working_dir: "/app" command: "node /app/server.js" diff --git a/load.js b/load.js index edef881..c5827bf 100644 --- a/load.js +++ b/load.js @@ -1,4 +1,4 @@ -const connection = new WebSocket('ws://localhost:8080'); +const connection = new WebSocket('ws://localhost:4242'); connection.onmessage = (e) => { var req = JSON.parse(e.data); if (req.name == 'pseudo') { @@ -35,7 +35,8 @@ window.onload = () => { }; } var play = document.getElementById('play'); - play.onclick = () => { + var pseudo = document.getElementById('pseudo'); + pseudo.onchange = play.onclick = () => { var pseudo = document.getElementById('pseudo').value; connection.send('{"name": "pseudo", "value": "'+pseudo+'"}'); }; diff --git a/server.js b/server.js index 6b5fdb3..45d2ee3 100644 --- a/server.js +++ b/server.js @@ -2,9 +2,8 @@ const fs = require('fs'); const http = require("http"); const ws = require('ws'); -const HTTP_PORT = 80; -const WS_PORT = 8080; -const DIR = "/app"; +const HTTP_PORT = 6969; +const WS_PORT = 4242; function update_player_list() { @@ -19,28 +18,28 @@ const requestListener = function (req, res) { if (url == "/" || url == "/index.html") { res.setHeader("Content-Type", "text/html"); res.writeHead(200); - res.end(fs.readFileSync(DIR + "/index.html")); + res.end(fs.readFileSync("./index.html")); return; } if (url == "/app.wasm") { res.setHeader("Content-Type", "application/wasm"); res.writeHead(200); - res.end(fs.readFileSync(DIR + url)); + res.end(fs.readFileSync("." + url)); return; } if (url == "/load.js") { res.setHeader("Content-Type", "text/javascript"); res.writeHead(200); - res.end(fs.readFileSync(DIR + url)); + res.end(fs.readFileSync("." + url)); return; } if (url.startsWith("/museum/")) { res.setHeader("Content-Type", "image/png"); res.writeHead(200); - res.end(fs.readFileSync(DIR + url)); + res.end(fs.readFileSync("." + url)); return; }