hello today we discuss a famous library for real time application
like chat app, gamming room etc.
socket.io is a server side library. its use in backend to send messages
that send bye user store the message and we send their message to client.
socket-client.io is a frontend library to connect server and using server link.
client emit the message to the server and server on their emit and server emit their message
and client on their emitted message into frontend side.
before message we make connection between so
//server.js
io.on('connection',(socket)=>{
console.log("connected")
socket.on('send_message',(msg)=>{
socket.emit('send_message',msg);
});
socket.on('disconnect',()=>{
console.log("disconnect")
})
});
//client.js
let msg="hi i am sandeep"
socket.emit('send_message',msg);
socket.on('send_message',msg=>{
console.log(msg)
});
Top comments (0)