From 8950c1bbdbe423b0f2f57d80f0abcc937cc0c9f7 Mon Sep 17 00:00:00 2001 From: ShadowCat567 Date: Tue, 23 Apr 2024 21:34:20 -0400 Subject: [PATCH] Should send message to one user --- back-end/Server.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/back-end/Server.js b/back-end/Server.js index 312763c..977acea 100644 --- a/back-end/Server.js +++ b/back-end/Server.js @@ -34,9 +34,7 @@ io.on('connection', (socket) => { console.log(`a user has connected, user id = ${socket.id}`); socket.on('chat_message', (msg, otherUser) => { - console.log(`Other user: ${otherUser}`); - console.log(msg); - io.emit('chat_message', msg); + io.to(otherUser).emit('chat_message', msg); //I think this will work... }); socket.on('disconnect', () => {