You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User Joined Room: Set(3) {
'koyFwiJ2_7V5Cc1nAAAP',
'96467dec-cf46-4890-b6f0-b5f116eb8158',
'room652'
}
This is the console for connecting the room. "room652" is my room id.
socket.on("new message", (newMessageReceived) => {
console.log("newMessageReceived", newMessageReceived); // new message
const chat = newMessageReceived.chat;
console.log("chat", chat);
if (!chat.users) return console.log("chat.users not defined");
chat.users.forEach((user) => {
if (user.user_id !== newMessageReceived.sender.user_id) {
console.log("user**user_id", user.user_id);
console.log("message received before emit", newMessageReceived);
// socket.to(user.user_id).emit('message received', newMessageReceived);
socket.to(user.user_id).emit("message received", newMessageReceived);
console.log("message received", `room`+chat.id);
socket.to(`room`+chat.id).emit("update last message", newMessageReceived); // last message emit to client
}
});
});
This socket "new message" is created for new message emit from client. That new message is received server. after that server emit the new message to client that is working like "socket.to(user.user_id).emit("message received", newMessageReceived);" this line. but when i emit update last message that not receive to client. i want update that last message in the chat list for particular chat.
The text was updated successfully, but these errors were encountered:
socket.on("join chat", (chatId) => {
socket.join("room"+chatId);
console.log("User Joined Room:", socket.rooms);
});
i connected the room using chatId.
User Joined Room: Set(3) {
'koyFwiJ2_7V5Cc1nAAAP',
'96467dec-cf46-4890-b6f0-b5f116eb8158',
'room652'
}
This is the console for connecting the room. "room652" is my room id.
socket.on("new message", (newMessageReceived) => {
console.log("newMessageReceived", newMessageReceived); // new message
});
This socket "new message" is created for new message emit from client. That new message is received server. after that server emit the new message to client that is working like "socket.to(user.user_id).emit("message received", newMessageReceived);" this line. but when i emit update last message that not receive to client. i want update that last message in the chat list for particular chat.
The text was updated successfully, but these errors were encountered: