Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
LminWoo99 committed Jul 5, 2024
1 parent b2829e3 commit 057080d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connec
return redisTemplate;
}
@Bean
public CacheManager testCacheManager(RedisConnectionFactory cf) {
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()))
.entryTtl(Duration.ofMinutes(3L));

return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(cf).cacheDefaults(redisCacheConfiguration).build();
}
@Bean
public RedisTemplate<String, ChatDto> redisTemplateForChatDto(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, ChatDto> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(connectionFactory);
Expand Down
46 changes: 0 additions & 46 deletions src/main/java/com/example/VideoChatting/config/SslConfig.java

This file was deleted.

96 changes: 48 additions & 48 deletions src/main/java/com/example/VideoChatting/config/WebRtcConfig.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
//package com.example.VideoChatting.config;
//
//import com.example.VideoChatting.service.rtc.KurentoHandler;
//import lombok.RequiredArgsConstructor;
//import org.kurento.client.KurentoClient;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.socket.config.annotation.EnableWebSocket;
//import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
//import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
//import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
//
//
//@Configuration
//@EnableWebSocket // 웹 소켓에 대해 자동 설정
//@RequiredArgsConstructor
//public class WebRtcConfig implements WebSocketConfigurer {
// /* TODO WebRTC 관련 */
//
//
// @Bean
// public KurentoHandler kurentoHandler(){
// return new KurentoHandler();
// }
// @Bean
// public KurentoClient kurentoClient() {
// String kurentoUrl = "ws://52.78.190.79:8888/kurento";
// return KurentoClient.create(kurentoUrl);
// }
//
//
// // signal 로 요청이 왔을 때 아래의 WebSockerHandler 가 동작하도록 registry 에 설정
// // 요청은 클라이언트 접속, close, 메시지 발송 등에 대해 특정 메서드를 호출한다
// @Override
// public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
// registry.addHandler(kurentoHandler(), "/signal")
// .setAllowedOrigins("*");
// }
//
// // 웹 소켓에서 rtc 통신을 위한 최대 텍스트 버퍼와 바이너리 버퍼 사이즈를 설정한다
// @Bean
// public ServletServerContainerFactoryBean createWebSocketContainer() {
// ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
// container.setMaxTextMessageBufferSize(32768);
// container.setMaxBinaryMessageBufferSize(32768);
// return container;
// }
//}
package com.example.VideoChatting.config;

import com.example.VideoChatting.service.rtc.KurentoHandler;
import lombok.RequiredArgsConstructor;
import org.kurento.client.KurentoClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;


@Configuration
@EnableWebSocket // 웹 소켓에 대해 자동 설정
@RequiredArgsConstructor
public class WebRtcConfig implements WebSocketConfigurer {
/* TODO WebRTC 관련 */


@Bean
public KurentoHandler kurentoHandler(){
return new KurentoHandler();
}
@Bean
public KurentoClient kurentoClient() {
String kurentoUrl = "ws://52.78.190.79:8888/kurento";
return KurentoClient.create(kurentoUrl);
}


// signal 로 요청이 왔을 때 아래의 WebSockerHandler 가 동작하도록 registry 에 설정
// 요청은 클라이언트 접속, close, 메시지 발송 등에 대해 특정 메서드를 호출한다
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(kurentoHandler(), "/signal")
.setAllowedOrigins("*");
}

// 웹 소켓에서 rtc 통신을 위한 최대 텍스트 버퍼와 바이너리 버퍼 사이즈를 설정한다
@Bean
public ServletServerContainerFactoryBean createWebSocketContainer() {
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
container.setMaxTextMessageBufferSize(32768);
container.setMaxBinaryMessageBufferSize(32768);
return container;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public void sendMessage(@Payload ChatDto chat) {
// Websocket에 발행된 메시지를 redis로 발행(publish)
redisPublisher.publish(chatRoomService.getTopic(chat.getRoomId()), message1);
chatService.saveMessage(chat);
// notificationService.notifyMessage(chatRoom.getRoomId(), chat.getSender());

// template.convertAndSend("/sub/chat/room/" + chat.getRoomId(), chat);

}
// 대화 내역 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@Setter
public class ChatRoomMap {
private static ChatRoomMap chatRoomMap = new ChatRoomMap();
// private Map<String, ChatRoom> chatRooms = new LinkedHashMap<>();
private ConcurrentMap<String, ChatRoom> chatRooms = new ConcurrentHashMap<>();
private ChatRoomMap(){}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ private Collection<String> joinRoom(KurentoUserSession newParticipant) throws IO
// participants 를 list 형태로 변환 => 이때 list 는 한명의 유저가 새로 들어올 때마다
// 즉 joinRoom 이 실행될 때마다 새로 생성 && return 됨
final List<String> participantsList = new ArrayList<>(participants.values().size());
// log.debug("ROOM {}: notifying other participants of new participant {}", name,
// newParticipant.getName());
log.debug("ROOM {}: 다른 참여자들에게 새로운 참여자가 들어왔음을 알림 {}", roomId,
newParticipant.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,4 @@ public interface ChatRoomRepository extends JpaRepository<ChatRoom, Long> {
@Query("update ChatRoom t set t.secretCheck = :secretCheck where t.roomId = :roomId")
void updateRoomSecretCheck(@Param("roomId")String roomId, @Param("secretCheck")Boolean secretCheck);

//// @Override
//// @EntityGraph(attributePaths = {"chatMessageList"})
//// List<ChatRoom> findAll();
// @Override
// @Query("SELECT b FROM ChatRoom b order by b.id desc")
// @EntityGraph(attributePaths = {"chatMessageList"})
// Page<ChatRoom> findAll(Pageable pageable);
// @Query("SELECT b FROM ChatRoom b order by b.id desc")
//// @EntityGraph(attributePaths = {"chatMessageList"})
// Slice<ChatRoom> findAllChatRooms(Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@
public interface ChatUserRepository extends JpaRepository<ChatUser, Long> {

Optional<ChatUser> findByEmail(String email);


Optional<ChatUser> findByNickname(String nickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public void saveMessage(ChatDto chatDto) {
chatDto.getMessage(), chatDto.getS3DataUrl(), room, chatDto.getRoomId(), chatDto.getFileName(), chatDto.getFileDir());
chatMessageRepository.save(chatMessage);

String cacheKey = "chat:" + chatDto.getRoomId();
redisTemplate.delete(cacheKey);
}
// 대화 조회 - Redis & DB
public List<ChatDto> loadMessage(String roomId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class KurentoService {
/**
* @desc room 정보를 담은 map
* */
// private final ConcurrentMap<String, KurentoRoom> rooms = new ConcurrentHashMap<>();
private final ConcurrentMap<String, ChatRoom> rooms = ChatRoomMap.getInstance().getChatRooms();

/**
Expand Down

0 comments on commit 057080d

Please sign in to comment.