Skip to content

Commit

Permalink
Merge pull request #111 from Leets-Official/dev
Browse files Browse the repository at this point in the history
Main 머지
  • Loading branch information
hyxklee authored Feb 5, 2025
2 parents eed7ef0 + a35bb50 commit 3d3085c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ public record AutoMatchingPostRequest(
// String destinationName,

// 현재 사용하는 필드
@NotNull
String startName,

@NotNull
String destinationName,

List<String> criteria,
@NotNull

List<Long> members,

@Min(value = 4000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public FindRoomResult toFindRoomResult() {
.roomId(this.getId())
.maxCapacity(this.getCapacity())
.chattingRoomId(this.chattingRoomId)
.currentMembers(this.getCurrentMemberCount())
.build();
}
public int getCurrentMemberCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ private void sendMatchRoomCreatedEvent(Long memberId,

private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) {
Long roomId = roomResult.roomId();
this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberJoinedEvent(roomId, memberId, roomResult.chattingRoomId()));
this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberJoinedEvent(roomId, memberId, roomResult.chattingRoomId(),
roomResult.currentMembers(), roomResult.maxCapacity()));
}

public AutoMatchingPostResponse handlerAutoCancelMatching(Long memberId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@ public void acceptInvitation(Long userId, ManualMatchingInviteReplyRequest reque

MemberMatchingRoomChargingInfo memberInfo = MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, member);
memberMatchingRoomChargingInfoRepository.save(memberInfo);

notificationRepository.delete(notification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public MatchMemberCancelledEvent createMatchMemberCancelledEvent(Long roomId, Lo
return MatchMemberCancelledEvent.of(roomId, memberId, this.matchMemberCancelledTopic);
}

public MatchMemberJoinedEvent createMatchMemberJoinedEvent(Long roomId, Long memberId, Long chattingRoomId) {
return MatchMemberJoinedEvent.of(roomId, memberId, this.matchMemberJoinedTopic, chattingRoomId);
public MatchMemberJoinedEvent createMatchMemberJoinedEvent(Long roomId, Long memberId, Long chattingRoomId, Integer nowMemberCount, Integer autoMaxCapacity) {
return MatchMemberJoinedEvent.of(roomId, memberId, this.matchMemberJoinedTopic, chattingRoomId, nowMemberCount, autoMaxCapacity);
}

public MatchRoomCancelledEvent createMatchRoomCancelledEvent(Long roomId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public record MatchMemberJoinedEvent(
Long roomId,
Long memberId,
Long chattingRoomId,
Integer nowMemberCount,
Integer maxCapacity,

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime joinedAt,
Expand All @@ -28,12 +30,14 @@ public String getTopic() {
return this.topic;
}

public static MatchMemberJoinedEvent of(Long roomId, Long memberId, String topic, Long chattingRoomId) {
public static MatchMemberJoinedEvent of(Long roomId, Long memberId, String topic, Long chattingRoomId, Integer nowMemberCount, Integer autoMaxCapacity) {
return MatchMemberJoinedEvent.builder()
.roomId(roomId)
.memberId(memberId)
.topic(topic)
.chattingRoomId(chattingRoomId)
.nowMemberCount(nowMemberCount)
.maxCapacity(autoMaxCapacity)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ public class AutoMatchingConsumer {
topics = "${gachtaxi.kafka.topics.match-room-created}",
containerFactory = "matchRoomCreatedEventListenerFactory"
)
public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) {
try {
log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event);
public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) {
try {
log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event);

this.sseService.sendToClient(
event.roomMasterId(),
"MATCH_ROOM_CREATED",
this.matchingRoomService.createMatchingRoom(event)
);
MatchRoomCreatedEvent createdEvent = this.matchingRoomService.createMatchingRoom(event);

ack.acknowledge();
this.sseService.sendToClient(
event.roomMasterId(),
"MATCH_ROOM_CREATED",
createdEvent
);

ack.acknowledge();
} catch (Exception e) {
log.error("[KAFKA CONSUMER] Error processing MatchRoomCreatedEvent", e);
this.sseService.sendToClient(event.roomMasterId(), "MATCH_ROOM_CREATED", e.getMessage());
Expand Down

0 comments on commit 3d3085c

Please sign in to comment.