Skip to content

last message is not emitting #5339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
santhanakumar45 opened this issue Apr 28, 2025 · 0 comments
Open

last message is not emitting #5339

santhanakumar45 opened this issue Apr 28, 2025 · 0 comments
Labels
to triage Waiting to be triaged by a member of the team

Comments

@santhanakumar45
Copy link

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

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.

@santhanakumar45 santhanakumar45 added the to triage Waiting to be triaged by a member of the team label Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage Waiting to be triaged by a member of the team
Projects
None yet
Development

No branches or pull requests

1 participant