October 2018
Intermediate to advanced
982 pages
23h 29m
English
We've coded our CommentService to implement Spring's WebSocketHandler interface, meaning, it's ready to transmit traffic over a WebSocket. The next step is to hook this service into the machinery.
We can start by creating a Spring configuration class:
@Configuration
public class WebSocketConfig {
...
}
This Spring configuration class is devoted to configuring WebSocket support, and is marked up with the @Configuration annotation, indicating it's a source of Spring bean definitions.
With that in place, we now come to the core piece of registering WebSocket functionality:
@Bean HandlerMapping webSocketMapping(CommentService commentService) { Map<String, WebSocketHandler> urlMap = new HashMap<>(); urlMap.put("/topic/comments.new", ...Read now
Unlock full access