From 77ee55eddbdbd029129961abc7ad726416a5d766 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Thu, 22 Oct 2026 09:27:50 -0600 Subject: [PATCH] started chat-io --- index.html | 40 +++++++++++++++++++++++++++++++++++++--- index.js | 9 +++++++++ package.json | 11 ++++++++--- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 5fd0af9..28172c3 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,44 @@ + + + Chat App + -

Hello from the other side, at least I can say that i've tried

+

Chad Chat

+ +
+ +
+ + + + + -

to tell you I'm sorry, for breaking your heart

- + diff --git a/index.js b/index.js index 2cd3773..99eb8a6 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,15 @@ app.get('/', (req, res) => { io.on('connection', (socket) => { console.log('New user connected'); + //Disconnect + socket.on('disconnect', () => { + console.log('A user has been disconnected'); + }); + //More. . . + socket.on('chat message', (msg) => { + console.log(msg); + io.emit('chat message', msg); + }); }); server.listen(3333, () => { diff --git a/package.json b/package.json index 01346ab..e38547a 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,12 @@ { - "name": "nodejs-first-example", + "name": "A chat application", "version": "1.0.0", - "description": "", + "description": "simple chat application using express and socket.io", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node index.js", + "dev": "nodemon index.js" }, "keywords": [], "author": "", @@ -12,5 +14,8 @@ "dependencies": { "express": "^4.22.3", "socket.io": "^4.8.4" + }, + "devDependencies": { + "nodemon": "^3.1.14" } }