Skip to content

Commit

Permalink
[fix] fix null point error & connect participant+room
Browse files Browse the repository at this point in the history
  • Loading branch information
drbug2000 committed Nov 3, 2024
1 parent b920fed commit 52f4414
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static VoiceRoomInfo convertRoomDto(RoomDto roomDto){
.order(roomDto.getOrder())
.metadate(roomDto.getMetadata())
.participantInfoList(
GetParticipantList.ParticipantInfo.convertParticipantDtoList(roomDto.getParticipantDtoList())
GetParticipantList.ParticipantInfo.convertParticipantDtoList(roomDto.getParticipantListDto().getParticipantDtoList())
)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ public class ParticipantListDto {
private ParticipantListDto(List<ParticipantDto> participantDtoList){
this.participantDtoList=participantDtoList;
}
public static ParticipantListDto from(List<ParticipantDto> participantDtoList ){

public static ParticipantListDto from(List<ParticipantDto> participantDtoList ){
return new ParticipantListDto(participantDtoList);
}
public static ParticipantListDto empty(){
return new ParticipantListDto(Collections.emptyList());
}

public static ParticipantListDto nullList(){
return new ParticipantListDto(null);
}

public void setProfileImage(Function<Long, String> profileFinder){
this.participantDtoList.forEach(participantDto -> {
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/space/space_spring/dto/VoiceRoom/RoomDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ public class RoomDto {
// .collect(Collectors.toList());
// }
public RoomDto setParticipantDTOList(List<ParticipantDto> participantDtoList){
this.participantListDto= ParticipantListDto.from(participantDtoList);
if(participantDtoList==null){
this.participantListDto = ParticipantListDto.empty();
}
this.participantListDto = ParticipantListDto.from(participantDtoList);
return this;
}

public RoomDto setParticipantDTOList(ParticipantListDto participants){
if(participants==null){
this.participantListDto = ParticipantListDto.empty();
}
this.participantListDto = participants;
return this;
}
Expand All @@ -50,7 +56,7 @@ public static RoomDto convertRoom(LivekitModels.Room room){
.startTime(room.getCreationTime())
.sid(room.getSid())
.metadata(room.getMetadata())
.participantListDto(null)
.participantListDto(ParticipantListDto.nullList())
.build();
}

Expand All @@ -72,7 +78,7 @@ public static RoomDto convertRoom(VoiceRoom voiceRoom){
.sid(null)
.metadata(null)
//.startTime()
.participantListDto(null)
.participantListDto(ParticipantListDto.nullList())
.build();
}

Expand Down Expand Up @@ -134,5 +140,5 @@ public String toString() {
}

public ParticipantListDto getParticipantListDto(){return participantListDto;}
public List<ParticipantDto> getParticipantDtoList(){return participantListDto.getParticipantDtoList();}
//public List<ParticipantDto> getParticipantDtoList(){return participantListDto.getParticipantDtoList();}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@ public List<GetVoiceRoomList.VoiceRoomInfo> convertVoicRoomInfoList() {
return convertVoicRoomInfoList( null);
}

public void serParticipantListDto(Map<Long,ParticipantListDto> participantListDtoMap){

for(RoomDto roomDto : this.roomDtoList){
roomDto.setParticipantDTOList(participantListDtoMap.get(roomDto.getId()));
}
}

}
2 changes: 1 addition & 1 deletion src/main/java/space/space_spring/entity/VoiceRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public RoomDto convertRoomDto(){
.sid(null)
.metadata(null)
//.startTime()
.participantDTOList(null)
.participantListDto(null)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Map<Long,ParticipantListDto> getParticipantList(List<Long> roomIdList){
return futureMap.entrySet().stream()
.collect(Collectors.toMap(
entry -> entry.getKey(),
entry->entry.getValue().getNow(ParticipantListDto.from(null))
entry->entry.getValue().getNow(ParticipantListDto.empty())
));

}catch (Exception e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public List<GetVoiceRoomList.VoiceRoomInfo> getVoiceRoomInfoListConcurrency(long


Map<Long,ParticipantListDto> roomIdParticipantMap=voiceRoomParticipantService.getParticipantList(roomIdList);
for(RoomDto roomDto : roomDtoList){
roomDto.setParticipantDTOList(roomIdParticipantMap.get(roomDto.getId()));
}


//ToDo Response로 convert
//#1 Active/inActive 분리
Expand Down

0 comments on commit 52f4414

Please sign in to comment.