Node_Chat_Server / index.js
Anuj-Panthri's picture
sent message console log
5d2be44
raw
history blame contribute delete
513 Bytes
const app = require("express")();
const http = require("http").createServer(app);
app.get('/',(req,res)=>{
res.send("Chat server is up and running!");
})
// Socket logic
const socketio = require("socket.io")(http);
//adding on connection event listener
socketio.on("connection",(userSocket)=>{
//socket listening for send_message
userSocket.on("send_message",(data)=>{
console.log("sent a message!");
userSocket.broadcast.emit("receive_message",data);
});
});
http.listen(8080)