DEV Community

Cover image for Socket.io Use as Real Time Application like Chatting Gamming in React ,Or Any Application in Express
Deepak Jaiswal
Deepak Jaiswal

Posted on

3 2

Socket.io Use as Real Time Application like Chatting Gamming in React ,Or Any Application in Express

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")
})

});
Enter fullscreen mode Exit fullscreen mode
//client.js

let msg="hi i am sandeep"

socket.emit('send_message',msg);


socket.on('send_message',msg=>{

console.log(msg)
});
Enter fullscreen mode Exit fullscreen mode

Image description

Imagine monitoring actually built for developers

Billboard image

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay