-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: EunJiJung <[email protected]>
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...nd/signaling-server/src/main/java/com/asyncgate/signaling_server/config/WebRTCConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.asyncgate.signaling_server.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
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; | ||
import sun.misc.SignalHandler; | ||
|
||
@Configuration | ||
@EnableWebSocket // 웹 소켓에 대해 자동 설정 | ||
@RequiredArgsConstructor | ||
public class WebRTCConfig implements WebSocketConfigurer { | ||
// WebRTC 시그널링을 처리할 핸들러 | ||
private final SignalHandler signalHandler; | ||
|
||
// WebSocket 핸들러 등록 | ||
@Override | ||
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { | ||
registry.addHandler(signalHandler, "/signal") | ||
.setAllowedOrigins("*"); | ||
} | ||
|
||
// WebSocket 텍스트 및 바이너리 버퍼 크기 설정 | ||
@Bean | ||
public ServletServerContainerFactoryBean createWebSocketContainer() { | ||
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean(); | ||
container.setMaxTextMessageBufferSize(32768); | ||
container.setMaxBinaryMessageBufferSize(32768); | ||
return container; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...signaling-server/src/main/java/com/asyncgate/signaling_server/config/WebSocketConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.asyncgate.signaling_server.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.messaging.simp.config.MessageBrokerRegistry; | ||
import org.springframework.web.socket.config.annotation.*; | ||
|
||
@Configuration | ||
@EnableWebSocketMessageBroker // 문자 채팅용 | ||
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { | ||
|
||
// 웹 소켓 연결을 위한 엔드포인트 설정 및 stomp sub/pub 엔드포인트 설정 | ||
@Override | ||
public void registerStompEndpoints(StompEndpointRegistry registry) { | ||
// stomp 접속 주소 url => /ws-stomp | ||
registry.addEndpoint("/ws-stomp") // 연결될 엔드포인트 | ||
.withSockJS(); // SocketJS 를 연결한다는 설정 | ||
} | ||
|
||
@Override | ||
public void configureMessageBroker(MessageBrokerRegistry registry) { | ||
// 메시지를 구독하는 요청 url => 즉 메시지 받을 때 | ||
registry.enableSimpleBroker("/sub"); | ||
|
||
// 메시지를 발행하는 요청 url => 즉 메시지 보낼 때 | ||
registry.setApplicationDestinationPrefixes("/pub"); | ||
} | ||
|
||
} |