Spring/기타 여러가지

Spring WebSocket, 스프링 공식문서

doriver 2025. 1. 29. 20:41

 

https://docs.spring.io/spring-framework/reference/

 

Spring Framework Documentation :: Spring Framework

Rod Johnson, Juergen Hoeller, Keith Donald, Colin Sampaleanu, Rob Harrop, Thomas Risberg, Alef Arendsen, Darren Davison, Dmitriy Kopylenko, Mark Pollack, Thierry Templier, Erwin Vervaet, Portia Tung, Ben Hale, Adrian Colyer, John Lewis, Costin Leau, Mark F

docs.spring.io

Web on Servlet Stack WebSockets
Servlet-stack web applications 
      built on the Servlet API 
      and deployed to Servlet containers
WebSocket messaging 
           that includes raw WebSocket interactions
, WebSocket emulation through SockJS
, and publish-subscribe messaging through STOMP 
             as a sub-protocol over WebSocket.

 

WebSocket API 1. WebSocketHandler
예) ~ extends TextWebSocketHandler 
      ~ implements WebSocketHandler
2. WebSocket Handshake
예) ~ implements HandshakeInterceptor
The Spring Framework provides a WebSocket API 
    that you can use to write client- and server-side applications 
           that handle WebSocket messages.

The easiest way to customize the initial HTTP WebSocket handshake request

                    is through a HandshakeInterceptor

You can use such an interceptor to preclude the handshake 

                                     or to make any attributes available to the WebSocketSession

A more advanced option is to extend the DefaultHandshakeHandler 

                                                               that performs the steps of the WebSocket handshake 

              , including validating the client origin, negotiating a sub-protocol, and other details.