From a6f50e74268b7f62ccf6eb2e30ee86e922bf036c Mon Sep 17 00:00:00 2001 From: kotto5 Date: Tue, 23 Jan 2024 09:50:09 +0900 Subject: [PATCH] [backend] Fix error in ChatGateway emit --- backend/src/chat/chat.gateway.ts | 4 +++- backend/test/chat-gateway.e2e-spec.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/chat/chat.gateway.ts b/backend/src/chat/chat.gateway.ts index 6906bd84..a5015958 100644 --- a/backend/src/chat/chat.gateway.ts +++ b/backend/src/chat/chat.gateway.ts @@ -109,7 +109,9 @@ export class ChatGateway { this.chatService.getInvite(data.userId) !== this.chatService.getUserId(client) ) { - client.emit('error-pong', 'No pending invite found.'); + this.server + .to(client.id) + .emit('error-pong', 'No pending invite found.'); return; } const emitData = { roomId: v4() }; diff --git a/backend/test/chat-gateway.e2e-spec.ts b/backend/test/chat-gateway.e2e-spec.ts index 238bfcea..0e71084d 100644 --- a/backend/test/chat-gateway.e2e-spec.ts +++ b/backend/test/chat-gateway.e2e-spec.ts @@ -1241,7 +1241,7 @@ describe('ChatGateway and ChatController (e2e)', () => { emitter.ws.on('match-pong', mockCallback1); errorCtx = new Promise((resolve) => - listener.ws.on('error-pong', (data) => resolve(data)), + emitter.ws.on('error-pong', (data) => resolve(data)), ); listener.ws.on('match-pong', mockCallback2);