79277018

Date: 2024-12-13 01:22:41
Score: 0.5
Natty:
Report link

This project helped me out: https://github.com/TomCools/dropwizard-websocket-jsr356-bundle.

If you are using Guice for DI, you'll want to add a Configurator:

  ServerEndpointConfig serverEndpointConfig = ServerEndpointConfig.Builder.create(MyWebsocketServer.class,
                                                                                    "/my-ws-enpoint")
            .configurator(new GuiceConfigurator())
            .build();

class GuiceConfigurator extends ServerEndpointConfig.Configurator {
        @Override
        public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
            return injector.getInstance(endpointClass);
        }
    }

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Mark