From b63ec11122553066d9217dd67fe2e133a3ecf9d4 Mon Sep 17 00:00:00 2001 From: odoacre <0d0acre@esiliati.org> Date: Fri, 4 Nov 2022 15:33:56 +0100 Subject: [PATCH] Use object instad of map Fix styles --- server/index.js | 11 ++++++----- server/public/index.html | 9 ++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/server/index.js b/server/index.js index a5b723c..42f41c3 100644 --- a/server/index.js +++ b/server/index.js @@ -8,7 +8,7 @@ const io = new Server(server); const { Readable } = require('stream'); const { parse } = require('node-html-parser'); -const names = new Map(); +const names = {}; const getName = async (category = "Informatica") => { const altre = ['Anarchici+italiani', 'Informatica', 'Distretti+dell%27Irlanda+del+Nord+soppressi'] @@ -57,14 +57,14 @@ app.get('/', (req, res) => { app.get('/waiting', (req, res) => { res.sendStatus(418); }); -app.get('/image', (req, res) => { - res.sendFile(path.join(__dirname, 'public', 'title.png')); + +app.get('/users', (req, res) => { + res.send(JSON.stringify(Object.values(names))); }); io.on('connection', async (socket) => { const { name: nameForUser, link } = await getName(); - names.set(socket.id, nameForUser); - + names[socket.id] = nameForUser; // Emit username and chat message socket.emit('username', `${nameForUser}@@@${link}`); socket.emit('chat message', `Ciao ${nameForUser}!`); @@ -80,6 +80,7 @@ io.on('connection', async (socket) => { socket.on('disconnect', () => { console.info(`${nameForUser} disconnected`); + delete names[socket.id]; }); }); diff --git a/server/public/index.html b/server/public/index.html index daa250f..557cb83 100644 --- a/server/public/index.html +++ b/server/public/index.html @@ -21,14 +21,15 @@ } #form { - background: rgba(0, 0, 0, 0.15); + border-top: 1px solid black; + background: #eee; padding: 0.25rem; position: absolute; bottom: 0; left: 0; right: 0; display: flex; - height: 8vh; + height: 3em; box-sizing: border-box; justify-content: center; } @@ -103,7 +104,9 @@

Hack or Di(Y|E) 8

-

Tu sei:

+ Lista utenti connessi - + Tu sei: +