diff --git a/back-end/Server.js b/back-end/Server.js index 977acea..5978121 100644 --- a/back-end/Server.js +++ b/back-end/Server.js @@ -33,8 +33,8 @@ io.use((socket, next) => { io.on('connection', (socket) => { console.log(`a user has connected, user id = ${socket.id}`); - socket.on('chat_message', (msg, otherUser) => { - io.to(otherUser).emit('chat_message', msg); //I think this will work... + socket.on('chat_message', (msg) => { + io.emit('chat_message', msg); }); socket.on('disconnect', () => { diff --git a/front-end/src/ChatPage.js b/front-end/src/ChatPage.js index ba1a85f..94a1ef1 100644 --- a/front-end/src/ChatPage.js +++ b/front-end/src/ChatPage.js @@ -70,7 +70,7 @@ function ChatPage() { //sends the message to the backend function sendToSocket(msg) { - socket.emit('chat_message', msg, otherperson_username); + socket.emit('chat_message', msg); } const getUser = async () => { @@ -139,7 +139,7 @@ function ChatPage() { if (message.sender === user) { return }else { - return + return } })}