Skip to content

Commit

Permalink
🔊 chore: socket 시험용 로그 (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
synoti21 committed Dec 4, 2023
1 parent 1cc917a commit 21e1613
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/domain/chat/chat.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand All @@ -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);
}
Expand All @@ -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);

Expand All @@ -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`);
}
}

0 comments on commit 21e1613

Please sign in to comment.