Java 类org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration 实例源码

项目:pinpoint    文件:WebSocketConfig.java   
@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);
    }
}
项目:wamp2spring    文件:WampConfiguration.java   
protected void configureWebSocketHandlerRegistration(
        @SuppressWarnings("unused") WebSocketHandlerRegistration registration) {
    // nothing here
}
项目:kurento-java    文件:JsonRpcConfiguration.java   
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());
    }
  }
}
项目:wamp2spring    文件:WampConfigurer.java   
/**
 * Configures the WebSocket handler registration
 *
 * <pre class="code">
 * &#64;Override
 * public void configureWebSocketHandlerRegistration(
 *      WebSocketHandlerRegistration registration) {
 *  registration.setAllowedOrigins("http://localhost:8100");
 * }
 * </pre>
 */
default void configureWebSocketHandlerRegistration(
        WebSocketHandlerRegistration registration) {
    // nothing here
}