better port

This commit is contained in:
nemo 2024-11-18 16:13:33 +01:00
parent cc7373f7b3
commit b4cc092247
3 changed files with 12 additions and 11 deletions

View File

@ -5,8 +5,9 @@ services:
container_name: "web" container_name: "web"
image: "node" image: "node"
ports: ports:
- "6969:80" - "6969:6969"
- "8080:8080" - "4242:4242"
volumes: volumes:
- ".:/app" - ".:/app"
working_dir: "/app"
command: "node /app/server.js" command: "node /app/server.js"

View File

@ -1,4 +1,4 @@
const connection = new WebSocket('ws://localhost:8080'); const connection = new WebSocket('ws://localhost:4242');
connection.onmessage = (e) => { connection.onmessage = (e) => {
var req = JSON.parse(e.data); var req = JSON.parse(e.data);
if (req.name == 'pseudo') { if (req.name == 'pseudo') {
@ -35,7 +35,8 @@ window.onload = () => {
}; };
} }
var play = document.getElementById('play'); var play = document.getElementById('play');
play.onclick = () => { var pseudo = document.getElementById('pseudo');
pseudo.onchange = play.onclick = () => {
var pseudo = document.getElementById('pseudo').value; var pseudo = document.getElementById('pseudo').value;
connection.send('{"name": "pseudo", "value": "'+pseudo+'"}'); connection.send('{"name": "pseudo", "value": "'+pseudo+'"}');
}; };

View File

@ -2,9 +2,8 @@ const fs = require('fs');
const http = require("http"); const http = require("http");
const ws = require('ws'); const ws = require('ws');
const HTTP_PORT = 80; const HTTP_PORT = 6969;
const WS_PORT = 8080; const WS_PORT = 4242;
const DIR = "/app";
function update_player_list() function update_player_list()
{ {
@ -19,28 +18,28 @@ const requestListener = function (req, res) {
if (url == "/" || url == "/index.html") { if (url == "/" || url == "/index.html") {
res.setHeader("Content-Type", "text/html"); res.setHeader("Content-Type", "text/html");
res.writeHead(200); res.writeHead(200);
res.end(fs.readFileSync(DIR + "/index.html")); res.end(fs.readFileSync("./index.html"));
return; return;
} }
if (url == "/app.wasm") { if (url == "/app.wasm") {
res.setHeader("Content-Type", "application/wasm"); res.setHeader("Content-Type", "application/wasm");
res.writeHead(200); res.writeHead(200);
res.end(fs.readFileSync(DIR + url)); res.end(fs.readFileSync("." + url));
return; return;
} }
if (url == "/load.js") { if (url == "/load.js") {
res.setHeader("Content-Type", "text/javascript"); res.setHeader("Content-Type", "text/javascript");
res.writeHead(200); res.writeHead(200);
res.end(fs.readFileSync(DIR + url)); res.end(fs.readFileSync("." + url));
return; return;
} }
if (url.startsWith("/museum/")) { if (url.startsWith("/museum/")) {
res.setHeader("Content-Type", "image/png"); res.setHeader("Content-Type", "image/png");
res.writeHead(200); res.writeHead(200);
res.end(fs.readFileSync(DIR + url)); res.end(fs.readFileSync("." + url));
return; return;
} }