sendToSpecificRoom(message: any): void {
if(message.roomName){
this.io.sockets.in(message.roomName).emit("eventSent", message);
}else{
this.io.sockets.emit("eventSent", message);
}
}
I need to send a message specifically to the sockets in a certain room. The "message" variable contains event data, including a property called roomName that I check to see if a room exists. How can I adjust the code above to achieve this?