'Send Response to one Room does not work (Nestjs & Socketio)
My goal is to emit to only one client by using the default room that is being created by socketIo.
The room id and client id match. I checked that by logging it. But if I execute it the server emit does not reach the client.
I got the following code.
SERVER:
export class BarGateway implements OnGatewayInit, OnGatewayConnection {
@WebSocketServer() server: Server;
@SubscribeMessage('prodOrderedToServer')
handleProdOrdered(client: Socket, payload: any): any {
this.server
.to(client.id)
.emit('prodOrderedToClient', client.id, 'response');
// this.server.emit('prodOrderedToClient');
}
}
CLIENT
io.on(PIC_ORDER_TO_CLIENT_EVENT, (payload: any) => {
queryClient.invalidateQueries(RQ_LAST_ORDER_LIST);
});
CONFIG
export const PIC_ORDER_TO_CLIENT_EVENT = 'prodOrderedToClient';
I have tried so many things and hope now that someone here can help me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
