From 18c3bb20e9b61dd2db4ec111a36256887c904672 Mon Sep 17 00:00:00 2001 From: dariolesa Date: Thu, 15 Oct 2026 11:02:04 -0600 Subject: [PATCH] sending a message in console when a user connects to the page --- index.html | 11 ++++++++--- index.js | 6 ++++++ package.json | 3 ++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 9f4104b..5f51ffe 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,10 @@ -

Hello Dario from index.html file

- -

Esta es una prueba de parrafo

+ + +

Hello Dario from index.html file

+

This is a text sample

+ + + + diff --git a/index.js b/index.js index 3497b97..cbe9294 100644 --- a/index.js +++ b/index.js @@ -2,12 +2,18 @@ const express = require('express'); const app = express(); const http = require('http'); const server = http.createServer(app); +const { Server } = require('socket.io'); +const io = new Server(server); app.get('/', (req, res) => { // res.send('

Hello Dario!

'); res.sendFile(__dirname + '/index.html'); }); +io.on('connection', (socket) => { + console.log('A new user is connected'); +}); + server.listen(3333, () => { console.log('listen on port 3333'); }); diff --git a/package.json b/package.json index 67a7230..06e4076 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "express": "^4.22.3" + "express": "^4.22.3", + "socket.io": "^4.8.4" } }