'Clear chat input box only for sender in socket.io
Hi I am making a online chatting app for all the person but when I send the message the chat input box is clear to everyone and I want to clear the chat input box only from sender I use this code in client.js to clear the chat input box but it clear from all the user browser
chatInputBox.innerHTML = "";
if anyone writing a message in chat box and another one send the message the chat input box is clear to everyone
is there is any solution of socket.io to solve this problem
Solution 1:[1]
That means that text is sent to everyone even to sender himself,
the way foward is on you're node.js server use socket.broadcast to send a message
so you dont need even to clear the inbox since sender wont even receive his own message
the code is socket.broadcast.emit("event_name", "message data - could be object");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ndotie |
