WebSocketHandlerthat initializes and destroys a
WebSocketHandlerinstance for each WebSocket connection and delegates all other methods to it.
If initializing the target
WebSocketHandler type requires a Spring
BeanFactory, then the
setBeanFactory(BeanFactory) property accordingly. Simply
declaring this class as a Spring bean will do that. Otherwise,
instances of the target type will be created using the default constructor.
- Rossen Stoyanchev
Method SummaryModifier and TypeMethodDescription
voidInvoked after the WebSocket connection has been closed by either side, or after a transport error has occurred.
voidInvoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.
voidInvoked when a new WebSocket message arrives.
voidHandle an error from the underlying WebSocket message transport.
voidCallback that supplies the owning factory to a bean instance.
booleanWhether the WebSocketHandler handles partial messages.
setBeanFactorypublic void setBeanFactory
(BeanFactory beanFactory)Description copied from interface:
BeanFactoryAwareCallback that supplies the owning factory to a bean instance.
Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()or a custom init-method.
afterConnectionEstablishedInvoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.
handleMessageInvoked when a new WebSocket message arrives.
handleTransportErrorHandle an error from the underlying WebSocket message transport.
afterConnectionClosedpublic void afterConnectionClosed
(WebSocketSession session, CloseStatus closeStatus) throws ExceptionInvoked after the WebSocket connection has been closed by either side, or after a transport error has occurred. Although the session may technically still be open, depending on the underlying implementation, sending messages at this point is discouraged and most likely will not succeed.
supportsPartialMessagespublic boolean supportsPartialMessages()Whether the WebSocketHandler handles partial messages. If this flag is set to
trueand the underlying WebSocket server supports partial messages, then a large WebSocket message, or one of an unknown size may be split and maybe received over multiple calls to
WebSocketHandler.handleMessage(WebSocketSession, WebSocketMessage). The flag
WebSocketMessage.isLast()indicates if the message is partial and whether it is the last part.
toStringpublic String toString()