/** * Configure one or more handlers to use depending on the sub-protocol requested by * the client in the WebSocket handshake request. * @param protocolHandlers the sub-protocol handlers to use */ public void setProtocolHandlers(List<SubProtocolHandler> protocolHandlers) { this.protocolHandlerLookup.clear(); this.protocolHandlers.clear(); for (SubProtocolHandler handler : protocolHandlers) { addProtocolHandler(handler); } }
@Override public StompWebSocketEndpointRegistration addEndpoint(String... paths) { this.subProtocolWebSocketHandler.addProtocolHandler(this.stompHandler); WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(paths, this.webSocketHandler, this.sockJsScheduler); this.registrations.add(registration); return registration; }
@Test public void getSubProtocols() throws Exception { SubscribableChannel channel = mock(SubscribableChannel.class); SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel); StompSubProtocolHandler stompHandler = new StompSubProtocolHandler(); handler.addProtocolHandler(stompHandler); TaskScheduler scheduler = mock(TaskScheduler.class); DefaultSockJsService service = new DefaultSockJsService(scheduler); WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null); SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session); assertEquals(stompHandler.getSupportedProtocols(), sockJsHandler.getSubProtocols()); }
/** * Configure one or more handlers to use depending on the sub-protocol requested by * the client in the WebSocket handshake request. * @param protocolHandlers the sub-protocol handlers to use */ public void setProtocolHandlers(List<SubProtocolHandler> protocolHandlers) { this.protocolHandlerLookup.clear(); this.protocolHandlers.clear(); for (SubProtocolHandler handler : protocolHandlers) { addProtocolHandler(handler); } }
/** * Configure one or more handlers to use depending on the sub-protocol requested by * the client in the WebSocket handshake request. * @param protocolHandlers the sub-protocol handlers to use */ public void setProtocolHandlers(List<SubProtocolHandler> protocolHandlers) { this.protocolHandlerLookup.clear(); this.protocolHandlers.clear(); for (SubProtocolHandler handler : protocolHandlers) { addProtocolHandler(handler); } }
@Override public StompWebSocketEndpointRegistration addEndpoint(String... paths) { this.subProtocolWebSocketHandler.addProtocolHandler(this.stompHandler); WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(paths, this.webSocketHandler, this.sockJsScheduler); this.registrations.add(registration); return registration; }
@Override public StompWebSocketEndpointRegistration addEndpoint(String... paths) { this.subProtocolWebSocketHandler.addProtocolHandler(this.stompHandler); WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(paths, this.webSocketHandler, this.sockJsScheduler); this.registrations.add(registration); return registration; }
@Override public WampWebSocketEndpointRegistration addEndpoint(String... paths) { this.subProtocolWebSocketHandler.addProtocolHandler(this.wampSubProtocolHandler); WebMvcWampWebSocketEndpointRegistration registration = new WebMvcWampWebSocketEndpointRegistration( paths, this.webSocketHandler, this.sockJsScheduler); this.registrations.add(registration); if (this.handshakeInterceptors != null && this.handshakeInterceptors.size() > 0) { registration.addInterceptors(this.handshakeInterceptors.toArray( new HandshakeInterceptor[this.handshakeInterceptors.size()])); } return registration; }
@Bean public SubProtocolWebSocketHandler subProtocolWebSocketHandler() { SubProtocolWebSocketHandler subProtocolWebSocketHandler = new SubProtocolWebSocketHandler( clientInboundChannel(), clientOutboundChannel()); subProtocolWebSocketHandler.addProtocolHandler(wampSubProtocolHandler()); return subProtocolWebSocketHandler; }