Skip to content

Commit

Permalink
Refactor : 커서 위치 전달시 색상 정보 추가 전달
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-Dong-Jun99 committed Jan 25, 2024
1 parent 5adcddf commit 1333f5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public record TripCursorMsg(
Long memberId,
String name,
Double x,
Double y
Double y,
String color
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
import static org.tenten.tentenstomp.domain.trip.dto.response.TripInfoMsg.fromEntity;
import static org.tenten.tentenstomp.domain.trip.dto.response.TripItemMsg.fromTripItemList;
import static org.tenten.tentenstomp.domain.trip.dto.response.TripMemberMsg.fromEntity;
import static org.tenten.tentenstomp.global.common.constant.TopicConstant.PATH;
import static org.tenten.tentenstomp.global.common.constant.TopicConstant.TRIP_ITEM;
import static org.tenten.tentenstomp.global.common.constant.TopicConstant.*;
import static org.tenten.tentenstomp.global.common.enums.Transportation.CAR;
import static org.tenten.tentenstomp.global.common.enums.Transportation.fromName;
import static org.tenten.tentenstomp.global.component.dto.request.TripPlace.fromTripItems;
Expand All @@ -48,6 +47,13 @@ public class TripService {
private final PathComponent pathComponent;
private final MessageProxyRepository messageProxyRepository;
private final SecurityUtil securityUtil;
private static final String[] COLORS = new String[]{
"#FF2167",
"#7932FF",
"#29DDF6",
"#FFAC16",
"#16E7A9"
};
private final Map<String, HashSet<Long>> tripConnectedMemberMap = new HashMap<>();
@Transactional
public void connectMember(String tripId, MemberConnectMsg memberConnectMsg) {
Expand Down Expand Up @@ -256,8 +262,8 @@ public void deleteTripMember(String tripId, Long memberId) {
public void updateCursor(String tripId, CursorUpdateMsg cursorUpdateMsg) {
Long memberId = securityUtil.getMemberId(cursorUpdateMsg.token());
Member member = memberRepository.getReferenceById(memberId);
TripCursorMsg tripCursorMsg = new TripCursorMsg(tripId, cursorUpdateMsg.visitDate(), memberId, member.getNickname(), cursorUpdateMsg.x(), cursorUpdateMsg.y());
kafkaProducer.sendAndSaveToRedis(tripCursorMsg);
TripCursorMsg tripCursorMsg = new TripCursorMsg(tripId, cursorUpdateMsg.visitDate(), memberId, member.getNickname(), cursorUpdateMsg.x(), cursorUpdateMsg.y(), COLORS[memberId % 5]);
kafkaProducer.send(CURSOR, tripCursorMsg);
}
@WithRedissonLock
@Transactional
Expand Down

0 comments on commit 1333f5f

Please sign in to comment.