Skip to content

Commit

Permalink
Merge pull request #103 from Wakttu/feat/cloud
Browse files Browse the repository at this point in the history
Fix  : Cloud Logic
  • Loading branch information
iqeq1945 authored Dec 21, 2024
2 parents 5442af4 + bf275d1 commit f75df57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 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 Expand Up @@ -1222,7 +1223,7 @@ export class SocketGateway
// ping
@SubscribeMessage('cloud.ping')
handleCloudPing(@MessageBody() roomId: string) {
let time = 60;
let time = 45;
const timeId = setInterval(() => {
this.server.to(roomId).emit('cloud.ping');
time--;
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 f75df57

Please sign in to comment.