@Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { final String[] allowedOriginArray = getAllowedOriginArray(configProperties.getWebSocketAllowedOrigins()); for (PinpointWebSocketHandler handler : handlerRepository.getWebSocketHandlerRepository()) { String path = handler.getRequestMapping() + WEBSOCKET_SUFFIX; final WebSocketHandlerRegistration webSocketHandlerRegistration = registry.addHandler(handler, path); webSocketHandlerRegistration.addInterceptors(new HttpSessionHandshakeInterceptor()); webSocketHandlerRegistration.addInterceptors(new WebSocketSessionContextPrepareHandshakeInterceptor()); webSocketHandlerRegistration.setAllowedOrigins(allowedOriginArray); } }
protected void configureWebSocketHandlerRegistration( @SuppressWarnings("unused") WebSocketHandlerRegistration registration) { // nothing here }
private void publishWebSocketEndpoint(WebSocketHandlerRegistry wsHandlerRegistry, JsonRpcHandler<?> handler, List<String> paths) { ProtocolManager protocolManager = (ProtocolManager) ctx.getBean("protocolManager", handler); JsonRpcWebSocketHandler wsHandler = new JsonRpcWebSocketHandler(protocolManager); protocolManager.setPingWachdog(handler.isPingWatchdog()); for (String path : paths) { WebSocketHandlerRegistration registration = wsHandlerRegistry.addHandler(wsHandler, path); List<String> origins = handler.allowedOrigins(); registration.setAllowedOrigins(origins.toArray(new String[origins.size()])); if (handler.isSockJSEnabled()) { registration.withSockJS().setSessionCookieNeeded(false); } if (handler.getLabel() != null) { wsHandler.setLabel(handler.getLabel()); } } }
/** * Configures the WebSocket handler registration * * <pre class="code"> * @Override * public void configureWebSocketHandlerRegistration( * WebSocketHandlerRegistration registration) { * registration.setAllowedOrigins("http://localhost:8100"); * } * </pre> */ default void configureWebSocketHandlerRegistration( WebSocketHandlerRegistration registration) { // nothing here }