From e38a2cba9a0b6f03b0ee2eed867821b1238ba824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Ant=C3=B4nio=20Farias=20Machado?= Date: Thu, 22 Jun 2023 10:58:26 -0300 Subject: [PATCH] chore(socketio): request to call another user --- backend/services/socketio/server.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/services/socketio/server.js b/backend/services/socketio/server.js index b2ef808..f308e57 100644 --- a/backend/services/socketio/server.js +++ b/backend/services/socketio/server.js @@ -19,13 +19,16 @@ io.on('connection', (socket) => { console.log(`🚀: ${socket.id} user just connected!`); socket.on("callUser", ({ userToCall, signalData, from }) => { - console.log("user to call: ",userToCall) - let index = users.findIndex(x =>{ x.name === userToCall}) + console.log("user to call:",userToCall) + let index = users.findIndex(x =>{ + return x.name === userToCall + }) + console.log(index) if (index >= 0){ console.log("calling user named "+ users[index].name+" and id "+users[index].id) - io.to(users[index].id).emit("callUser", { signal: signalData, from, name }); + io.to(users[index].id).emit("callUser", { signal: signalData, from }); }else{ - console.log("There is no user named "+userToCall+" or it's he/she is offline") + console.log("There is no user named "+userToCall+" or he/she is offline") } });