Search code examples
grailswebsocketspring-websocketgrails-3.0

Access WebSocketConfigurer with Grails 3 spring-websocket


I'm trying to register a WebsocketHandler in a Grails 3.2.x app with the spring-websocket plugin.

I tried creating a custom websocketConfig with the grails create-web-socket-config command, but the resulting class does not implement org.springframework.web.socket.config.annotation.WebSocketConfigurer to be able to add handlers to with the registerWebSocketHandlers(WebSocketHandlerRegistry registry) event.

How would I be able to do this within an AbstractWebSocketMessageBrokerConfigurer?


Solution

  • within an AbstractWebSocketMessageBrokerConfigurer, you wont be able to do that.

    but you should be able to just supply another @EnableWebSocket annotated @Configuration bean implementing WebSocketConfigurer that is picked up by component scan or you register it manually in resources.groovy.

    ref. http://docs.spring.io/spring/docs/4.3.4.RELEASE/spring-framework-reference/html/websocket.html#websocket-server-handler