disconnect and nodemon

events
Gerardo Marx 4 weeks ago
parent 3255674aa2
commit e52307ee4d

3
.gitignore vendored

@ -0,0 +1,3 @@
node_modules/
package-lock.json
*.*.swp

@ -1,7 +1,7 @@
<html> <html>
<body> <body>
<h1> Hello Marx from index.html file </h1> <h1> Hello Marx from index.html file </h1>
<p>This is some text</p> <p>This is some new text recently added</p>
<script src='/socket.io/socket.io.js'></script> <script src='/socket.io/socket.io.js'></script>
<script>var socket = io();</script> <script>var socket = io();</script>
</body> </body>

@ -13,6 +13,9 @@ app.get('/', (req, res) => {
io.on('connection', (socket) => { io.on('connection', (socket) => {
console.log('A new user is connected'); console.log('A new user is connected');
socket.on('disconnect', ()=> {
console.log('User disconnected');
});
}); });
server.listen(3333, () => { server.listen(3333, () => {

@ -4,7 +4,9 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "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": [], "keywords": [],
"author": "", "author": "",
@ -12,5 +14,8 @@
"dependencies": { "dependencies": {
"express": "^4.22.3", "express": "^4.22.3",
"socket.io": "^4.8.4" "socket.io": "^4.8.4"
},
"devDependencies": {
"nodemon": "^3.1.14"
} }
} }

Loading…
Cancel
Save