From e216a665662522f0422264e82e14a2c2740503d6 Mon Sep 17 00:00:00 2001 From: HeeDragoN1123 Date: Mon, 13 Nov 2023 21:27:12 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20chat=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ src/chats/chats.gateway.ts | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 16813cb..3f78be3 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@

## ๐Ÿ‘ฅ ์ฐธ๊ฐ€ํ•œ ์‚ฌ๋žŒ๋“ค + +![Project Logo](images/catheeyong.jpg) + diff --git a/src/chats/chats.gateway.ts b/src/chats/chats.gateway.ts index 7dc49e2..20c3b3f 100644 --- a/src/chats/chats.gateway.ts +++ b/src/chats/chats.gateway.ts @@ -107,13 +107,15 @@ export class ChatsGateway ); // MongoDB์˜ socketModel์— ์‚ฌ์šฉ์ž ์ •๋ณด ์ €์žฅ - await this.socketModel.create({ + const userInfo = await this.socketModel.create({ socketId: socket.id, nickname: payload.nickname, roomId: payload.roomId, profileImg: payload.profileImg, userId: payload.userId, }); + // sockets db์— ์ €์žฅ๋œ ์œ ์ €์ •๋ณด๋ฅผ userList๋ฐฐ์—ด์— ์ถ”๊ฐ€ + this.userList.push(userInfo); // ์ด์ „ ์ฑ„ํŒ… ๋‚ด์šฉ์„ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค. const chatHistory = await this.getChatHistory(payload.roomId); @@ -127,6 +129,7 @@ export class ChatsGateway // ์ด์ „ ์ฑ„ํŒ… ๋‚ด์šฉ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „์†กํ•ฉ๋‹ˆ๋‹ค. socket.emit('chat_history', chatHistory); + // this.server.to(String(payload.roomId)).emit('chat_history', chatHistory); // ๋ฐฉ์— ์žˆ๋Š” ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ userList ์ „์†ก this.server.to(String(payload.roomId)).emit('user_connected', payload); // console.log('์œ ์ €๋ฆฌ์ŠคํŠธ ์ฝ˜์†”', this.userList); @@ -174,7 +177,6 @@ export class ChatsGateway nickname: messageData.nickname, profileImg: messageData.profileImg, roomId: messageData.roomId, - time: messageData.time, chat: messageData.message, // ์ˆ˜์ •: messageData.message๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฑ„ํŒ… ์ €์žฅ });
์ด๋ฆ„