Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWL-282] Json 직렬화 문제, 연결할 때, 소켓에 나머지 인원이 들어오지 못하는 문제 #283

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class ExtensionWebSocketServer {
const curRoom = this.rooms.get(roomId);
curRoom.delete(clientId);
await this.redisData.srem(roomId, clientId);
await this.redisData.del(`userMatch:${clientId}`);
if (curRoom.size === 0) {
this.unSubscribe(`channel/${roomId}`);
}
Expand Down Expand Up @@ -110,7 +111,7 @@ export class ExtensionWebSocketServer {
client.send(
JSON.stringify({
event: jsonMessage.event,
data: jsonMessage.message,
data: JSON.parse(jsonMessage.message),
}),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const ALONE_USER = 1;
export const WAITING_20_TIME = 20;
export const MATCHING_DELAY = 15;
export const UTC_REMOVE_TIME = 600;
export const MATCHES_API_TIME_OUT = 10000;
export const MATCHES_API_TIME_OUT = 20;
14 changes: 5 additions & 9 deletions BackEnd/src/live-workouts/matches/matches.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
WAITING_20_TIME,
ALONE_USER,
MATCHING_DELAY,
UTC_REMOVE_TIME,
MATCHES_API_TIME_OUT,
UTC_REMOVE_TIME, MATCHES_API_TIME_OUT,
} from './constant/matches.constant';

@Injectable()
Expand Down Expand Up @@ -104,7 +103,7 @@ export class MatchesService {

const liveWorkoutStartTime = new Date();
liveWorkoutStartTime.setSeconds(
liveWorkoutStartTime.getSeconds() + 15,
liveWorkoutStartTime.getSeconds() + MATCHING_DELAY,
);
const kstTime = new Date(liveWorkoutStartTime.getTime() + (9 * 60 * 60 * 1000));
const liveWorkoutStartTimeUTC = kstTime.toISOString()
Expand All @@ -114,18 +113,15 @@ export class MatchesService {

const multi = this.redis.multi();
for (const { publicId } of profiles) {
multi.set(`userMatch:${publicId}`, roomId, 'EX', MATCHES_API_TIME_OUT);
multi.set(`userMatch:${publicId}`, roomId);
}

multi.set(
`matchProfiles:${roomId}`,
JSON.stringify(profiles),
'EX',
MATCHES_API_TIME_OUT,
);
JSON.stringify(profiles), 'EX', MATCHES_API_TIME_OUT);
multi.set(
`matchStartTime:${roomId}`,
JSON.stringify(liveWorkoutStartTimeUTC),
liveWorkoutStartTimeUTC,
);
multi.expire(`matchStartTime:${roomId}`, UTC_REMOVE_TIME);
multi.ltrim(`matching:${workoutId}`, waitingUsers, -1);
Expand Down
Loading