Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Create a chatbot using socket.io

I am creating a chatbot using socket.io. But I am facing some problems in implementation.
I want the server to respond to each client based on their request, but instead, the server broadcasts the message to all connected clients to the server.

It behaves more like a group chat, but I want to do a one-on-one chat with the backend server.

How to resolve this issue?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

faced the Same issue few days back

For me it resolved the issue

Instead of using io.emit() or socket.broadcast.emit() methods, use the socket.emit() method to send responses back to the specific client that initiated the request. You can access the specific socket instance from the server-side socket.io object to send the response to the correct client

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading