From 21e1613e668994387ee77bacd65aec0b86b7ee85 Mon Sep 17 00:00:00 2001 From: Ahn Jiwan Date: Mon, 4 Dec 2023 19:49:48 +0900 Subject: [PATCH] =?UTF-8?q?:loud=5Fsound:=20chore:=20socket=20=EC=8B=9C?= =?UTF-8?q?=ED=97=98=EC=9A=A9=20=EB=A1=9C=EA=B7=B8=20(#66)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/chat/chat.gateway.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/domain/chat/chat.gateway.ts b/src/domain/chat/chat.gateway.ts index f64fe04..73c9d3c 100644 --- a/src/domain/chat/chat.gateway.ts +++ b/src/domain/chat/chat.gateway.ts @@ -3,7 +3,7 @@ import { SubscribeMessage, MessageBody, ConnectedSocket, - WebSocketServer, + WebSocketServer, OnGatewayConnection, } from '@nestjs/websockets'; import { Server, Socket } from 'socket.io'; import { UseGuards } from '@nestjs/common'; @@ -15,7 +15,7 @@ import { CreateChatDto } from './dto/create-chat.dto'; namespace: 'chat', cors: true, }) -export class ChatGateway { +export class ChatGateway implements OnGatewayConnection{ @WebSocketServer() server: Server; @@ -26,6 +26,7 @@ export class ChatGateway { @MessageBody() data: { familyId: string }, @ConnectedSocket() client: Socket, ) { + console.log(data.familyId); const familyId = data.familyId; client.join(familyId); } @@ -35,6 +36,7 @@ export class ChatGateway { @MessageBody() createChatDto: CreateChatDto, @ConnectedSocket() client: Socket, ) { + console.log(createChatDto); const createDate = new Date(); await this.chatService.saveChat(createChatDto, createDate); @@ -54,4 +56,8 @@ export class ChatGateway { const familyId = data.familyId; client.leave(familyId); } + + handleConnection(@ConnectedSocket() socket: Socket): any { + console.log(`${socket.id} socket connected`); + } }