Skip to content
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 @@ -49,11 +49,9 @@ public class ChatMessageDto {
private List<Long> targetMemberIds; // 메시지 대상자 목록 (DM일 경우)

// CREATE 시 필요
@PastOrPresent(message = "생성 시간은 현재 시간 이전이어야 합니다.")
private LocalDateTime createdAt;

// UPDATE 시 필요
@PastOrPresent(message = "수정 시간은 현재 시간 이전이어야 합니다.")
private LocalDateTime updatedAt;

// @JsonCreator와 @JsonProperty를 사용한 생성자
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public void updateActualStatus(PresenceType actualStatus) {
calculateGlobalStatus();
}

public boolean existsDevice(String sessionId) {
for (DeviceInfo deviceInfo : devices) {
if (deviceInfo.getSocketSessionId().equals(sessionId)) {
return true;
}
}
return false;
}

public void updateCustomStatus(PresenceType customStatus) {
this.customStatus = customStatus;
calculateGlobalStatus();
Expand All @@ -48,7 +57,7 @@ public void deleteDevice(String sessionId) {
calculateGlobalStatus();
}

private void calculateGlobalStatus() {
public void calculateGlobalStatus() {
if (devices == null || devices.isEmpty() || actualStatus == PresenceType.OFFLINE) {
actualStatus = PresenceType.OFFLINE;
globalStatus = PresenceType.OFFLINE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,24 @@ private MemberPresenceStatus handleConnectionEvent(ConnectionEventDto connection
memberPresenceStatus.updateLastActivityTime(LocalDateTime.now());
}

DeviceInfo deviceInfo = DeviceInfo.builder()
.platform(connectionEventDto.getPlatform())
.socketSessionId(connectionEventDto.getSocketSessionId())
.connectedServerIp(connectionEventDto.getConnectedServerIp())
.lastActiveTime(LocalDateTime.now())
.build();

// 안드로이드 기기인 경우, 로컬에 있던 정보가 있다면 현재 채널 정보를 업데이트
if (deviceInfo.getPlatform().equals("ANDROID") && connectionEventDto.getCurrentChannelType() != null) {
deviceInfo.updateCurrent(connectionEventDto.getCurrentChannelType(),
connectionEventDto.getCurrentChannelId(), connectionEventDto.getCurrentServerId());
if (!memberPresenceStatus.existsDevice(connectionEventDto.getSocketSessionId())) {
DeviceInfo deviceInfo = DeviceInfo.builder()
.platform(connectionEventDto.getPlatform())
.socketSessionId(connectionEventDto.getSocketSessionId())
.connectedServerIp(connectionEventDto.getConnectedServerIp())
.lastActiveTime(LocalDateTime.now())
.build();

// 안드로이드 기기인 경우, 로컬에 있던 정보가 있다면 현재 채널 정보를 업데이트
if (deviceInfo.getPlatform().equals("ANDROID") && connectionEventDto.getCurrentChannelType() != null) {
deviceInfo.updateCurrent(connectionEventDto.getCurrentChannelType(),
connectionEventDto.getCurrentChannelId(), connectionEventDto.getCurrentServerId());
}

memberPresenceStatus.getDevices().add(deviceInfo);
}

memberPresenceStatus.getDevices().add(deviceInfo);
memberPresenceStatus.calculateGlobalStatus();

memberRedisRepositoryImpl.saveMemberPresenceStatus(connectionEventDto.getMemberId(), memberPresenceStatus);

Expand All @@ -135,6 +139,7 @@ private MemberPresenceStatus handleDisconnectionEvent(ConnectionEventDto connect
memberRedisRepositoryImpl.saveMemberPresenceStatus(connectionEventDto.getMemberId(), memberPresenceStatus);
}

memberPresenceStatus.calculateGlobalStatus();
memberRedisRepositoryImpl.saveMemberPresenceStatus(connectionEventDto.getMemberId(), memberPresenceStatus);
return memberPresenceStatus;
}
Expand Down