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"
image: "node"
ports:
- "6969:80"
- "8080:8080"
- "6969:6969"
- "4242:4242"
volumes:
- ".:/app"
working_dir: "/app"
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) => {
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+'"}');
};

View File

@ -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;
}