spring-framework / org.springframework.web.socket.handler / PerConnectionWebSocketHandler

PerConnectionWebSocketHandler

open class PerConnectionWebSocketHandler : WebSocketHandler, BeanFactoryAware

A WebSocketHandler that initializes and destroys a WebSocketHandler instance for each WebSocket connection and delegates all other methods to it.

Essentially create an instance of this class once, providing the type of WebSocketHandler class to create for each connection, and then pass it to any API method that expects a WebSocketHandler.

If initializing the target WebSocketHandler type requires a Spring BeanFctory, then the #setBeanFactory(BeanFactory) property accordingly. Simply declaring this class as a Spring bean will do that. Otherwise, WebSocketHandler instances of the target type will be created using the default constructor.

Author
Rossen Stoyanchev

Since
4.0

Constructors

<init>

PerConnectionWebSocketHandler(handlerType: Class<out WebSocketHandler>)
PerConnectionWebSocketHandler(handlerType: Class<out WebSocketHandler>, supportsPartialMessages: Boolean)

Functions

afterConnectionClosed

open fun afterConnectionClosed(session: WebSocketSession, closeStatus: CloseStatus): Unit

afterConnectionEstablished

open fun afterConnectionEstablished(session: WebSocketSession): Unit

handleMessage

open fun handleMessage(session: WebSocketSession, message: WebSocketMessage<*>): Unit

handleTransportError

open fun handleTransportError(session: WebSocketSession, exception: Throwable): Unit

setBeanFactory

open fun setBeanFactory(beanFactory: BeanFactory): Unit

supportsPartialMessages

open fun supportsPartialMessages(): Boolean

toString

open fun toString(): String