// server.js
const express = require('express');
const app = express();
const http = require('http').createServer(app);
const io = require('socket.io')(http);
let messages = [];
const html = `
✝ ChatCristiana Simple
`;
app.get('/',(req,res)=>res.send(html));
io.on('connection',socket=>{
socket.on('join',data=>{
messages.forEach(m=>socket.emit('chat message',m));
});
socket.on('chat message',data=>{
messages.push(data);
io.emit('chat message',data);
});
});
http.listen(3000,()=>console.log('Servidor en http://localhost:3000'));
Bienvenido a ChatCristiana
✝ ChatCristiana