Skip to content

Commit

Permalink
fix : enter room logic 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
iqeq1945 committed Dec 21, 2024
1 parent fcdc3e3 commit bf275d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/socket/socket.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ export class SocketGateway
this.user[client.id].id,
roomId,
);

client.join(roomId);
this.user[client.id].roomId = roomId;
this.server.to(roomId).emit('enter', {
Expand Down Expand Up @@ -1187,7 +1188,7 @@ export class SocketGateway
}
this.handleReady(roomId, client);

if (this.ping[roomId]) this.handlePong(roomId);
if (this.ping[roomId]) this.handleCloudPong(roomId);

await this.cloudService.handleStart(
roomId,
Expand Down
7 changes: 7 additions & 0 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ export class UserService {

async enter(id: string, roomId: string) {
try {
const room = await this.prisma.room.findUnique({
where: { id: roomId },
select: { start: true },
});
if (room.start) {
throw new Error('이미 시작된 방입니다.');
}
const response = await this.prisma.user.update({
where: { id },
data: {
Expand Down

0 comments on commit bf275d1

Please sign in to comment.