I was trying the tutorial provided by spring - messaging-stomp-websocket and it is working fine
Now I want to extend the this and add my WebSocket handler which intercept the channel.
public class WebSocketHandlerSpring extends TextWebSocketHandler {
@Override
public void handleTextMessage(WebSocketSession session, TextMessage message) {
}
}
This handler to WebSocketConfig class.
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/hello").withSockJS();
}
}
Any help how to configure WebSocketHandlerSpring
handler to WebSocketConfig
?
Raw WebSocketHandler
support comes from @EnableWebSocket
(not @EnableWebSocketMessageBroker
). You need to add that and implement WebSocketConfigurer
to register your endpoints. Example here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.