socket.io tested

main
Gerardo Marx 7 hours ago
parent 6a5974b07a
commit 3255674aa2

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

@ -2,12 +2,19 @@ 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('<h1> Hello Marx!</h1>');
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');
});

@ -10,6 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.22.3"
"express": "^4.22.3",
"socket.io": "^4.8.4"
}
}

Loading…
Cancel
Save