Skip to content

Commit

Permalink
Merge pull request #1 from ESC-CoM/fix/socket-connetion
Browse files Browse the repository at this point in the history
[fix] 채팅 namespace 추가 및 chat-rooms/me 404 에러 수정
  • Loading branch information
juyeong-s authored Jul 6, 2024
2 parents f5aa1b8 + 82c1344 commit 2ceef34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
21 changes: 18 additions & 3 deletions src/chat/chat.gateway.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import {
MessageBody,
SubscribeMessage,
WebSocketGateway,
WebSocketServer,
} from '@nestjs/websockets';
import { Socket } from 'net';
import { Server } from 'socket.io';

@WebSocketGateway()
@WebSocketGateway(3600, {
namespace: 'chat-rooms',
})
export class ChatGateway {
@WebSocketServer()
public io: Server;

handleConnection(client: any) {
const socketId = client.id;
this.io.emit('connection', { state: 'success', socketId });
}

@SubscribeMessage('message')
handleMessage(client: any, payload: any): string {
return 'Hello world!';
handleMessage(client: Socket, query: string) {
//
}

@SubscribeMessage('events')
handleEvent(@MessageBody() data: string): string {
return data;
}
}
11 changes: 0 additions & 11 deletions src/common/mongo.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export abstract class BaseRepository<TDocument extends BaseSchema> {

async findOne(filterQuery: FilterQuery<TDocument>) {
const document = await this.model.findOne(filterQuery, {}, { lean: true });

if (!document) {
this.logger.warn('Document not found with filterQuery', filterQuery);
throw new NotFoundException('Document not found.');
}
return document;
}

Expand All @@ -52,12 +47,6 @@ export abstract class BaseRepository<TDocument extends BaseSchema> {
lean: true,
new: true,
});

if (!document) {
this.logger.warn(`Document not found with filterQuery:`, filterQuery);
throw new NotFoundException('Document not found.');
}

return document;
}

Expand Down
2 changes: 2 additions & 0 deletions src/room/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export class RoomService {

public async search(userId: string) {
const user = await this.userService.findById(userId);
if (!user) return [];

const rooms = user.rooms.map((room) => room.room);
const meetings = await this.meetingService.findByIdIn(
rooms.map((room) => room.meeting.id),
Expand Down

0 comments on commit 2ceef34

Please sign in to comment.