Socket joins a room on connection, the room name can be found on rooms set defined on socket itself, but when an event is fired to that room, it doesn't receive that. Can someone figure out the issue with my code?
Joining
this.socketIOServer.on('connect', async (socket: AuthenticatedSocket) => {
if (socket?.request?.user?.id) {
await socket.join(socket.request.user.id);
console.log(socket.rooms); // Set(2) { 'j462VueHBUxufBucAAAB', '62c16b98be39c3605f03fd5a' }
}
});
Emitting
console.log(
'Sockets',
AppointmentsSocketService.server.sockets.sockets.forEach(s => {
console.log(s.rooms); // Set(2) { 'j462VueHBUxufBucAAAB', '62c16b98be39c3605f03fd5a' } Found in output
}),
);
/* EMIT EVENT TO ROOM */
AppointmentsSocketService.server
.to(appointment.patient.id) // id is exactly as room name '62c16b98be39c3605f03fd5a'
.emit('appointments/status', appointment);
console.log(
'Sockets',
AppointmentsSocketService.server.sockets.sockets.forEach(s => {
console.log(s.rooms); // Set(2) { 'j462VueHBUxufBucAAAB', '62c16b98be39c3605f03fd5a' } Found in output
}),
);
I'm testing through postman, & that never receives the response. I also try using Firecamp app as well as wrote dummy script to test - but never received event.