Java Code Examples for org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry#addHandler()

The following examples show how to use org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry#addHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebSocketConfig.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    final String[] allowedOriginArray = getAllowedOriginArray(configProperties.getWebSocketAllowedOrigins());

    for (PinpointWebSocketHandler handler : handlerRepository.getWebSocketHandlerRepository()) {
        String path = handler.getRequestMapping() + WEBSOCKET_SUFFIX;

        WebSocketHandler webSocketHandler = webSocketHandlerDecoratorFactory.decorate(handler);
        final WebSocketHandlerRegistration webSocketHandlerRegistration = registry.addHandler(webSocketHandler, path);

        webSocketHandlerRegistration.addInterceptors(new HttpSessionHandshakeInterceptor());
        webSocketHandlerRegistration.addInterceptors(new WebSocketSessionContextPrepareHandshakeInterceptor());
        if (Objects.nonNull(customHandshakeInterceptor)) {
            webSocketHandlerRegistration.addInterceptors(customHandshakeInterceptor);
        }
        webSocketHandlerRegistration.setAllowedOrigins(allowedOriginArray);
    }
}
 
Example 2
Source File: WebSocketConfig.java    From mySSM with MIT License 5 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    //WebIM WebSocket通道
    registry.addHandler(chatWebSocketHandler(),"/webSocketIMServer");
    registry.addHandler(chatWebSocketHandler(),"/sockjs/webSocketIMServer");
    registry.addHandler(chatWebSocketHandler(), "/sockjs/webSocketIMServer").withSockJS();
}
 
Example 3
Source File: GemWebSocketConfig.java    From gem with MIT License 5 votes vote down vote up
/**
 * 设置连接地址和拦截器
 */
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
	System.out.println("1111111111111111111111111111111111111");
	// 设置websocket的连接地址
	WebSocketHandlerRegistration addHandler = registry.addHandler(webSocketMessage(), "/");
	// 设置websocket的拦截器
	WebSocketHandlerRegistration addInterceptors = addHandler.addInterceptors(new GemWebSocketInterceptor());
	// 设置跨域请求
	addInterceptors.setAllowedOrigins("*");
}
 
Example 4
Source File: KurentoRoomServerApp.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(groupCallHandler(), "/room");
}
 
Example 5
Source File: SendDataChannelApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(handler(), "/senddatachannel");
}
 
Example 6
Source File: One2OneCallAdvApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(callHandler(), "/call");
}
 
Example 7
Source File: One2OneCallApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(callHandler(), "/call");
}
 
Example 8
Source File: MagicMirrorApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(handler(), "/magicmirror");
}
 
Example 9
Source File: PlayerApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(handler(), "/player");
}
 
Example 10
Source File: HelloWorldRecApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(handler(), "/repository");
}
 
Example 11
Source File: GroupCallApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(groupCallHandler(), "/groupcall");
}
 
Example 12
Source File: MetadataApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(handler(), "/metadata");
}
 
Example 13
Source File: WebsocketConfiguration.java    From onboard with Apache License 2.0 4 votes vote down vote up
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    registry.addHandler(websocketHandler, "/websocket");
}
 
Example 14
Source File: WebSocketConfig.java    From cloudterm with MIT License 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    registry
            .addHandler(terminalSocket(), "/terminal");
}
 
Example 15
Source File: HelloWorldRecApp.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
  registry.addHandler(handler(), "/recording");
}
 
Example 16
Source File: JavametricsSpringConfigurer.java    From javametrics with Apache License 2.0 4 votes vote down vote up
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
	registry.addHandler(new JavametricsSpringSocketHandler(), "javametrics-dash/javametrics-socket");
}
 
Example 17
Source File: ChatSocketConfig.java    From Spring-5.0-Cookbook with MIT License 4 votes vote down vote up
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
	registry.addHandler(new HotlineSocketHandler(), "/data");
}
 
Example 18
Source File: GatewayWebSocketConfigurer.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    String webSocketPath = "/ws/**";
    log.debug("Registering WebSocket proxy handler to " + webSocketPath);
    registry.addHandler(webSocketProxyServerHandler, webSocketPath);
}
 
Example 19
Source File: Application.java    From kurento-tutorial-java with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry)
{
  registry.addHandler(handler(), "/helloworld");
}
 
Example 20
Source File: DiscoverableClientWebSocketConfigurer.java    From api-layer with Eclipse Public License 2.0 3 votes vote down vote up
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    String webSocketEndpoint = "/ws/uppercase";

    logger.log("org.zowe.apiml.sampleservice.log.registeringWebSocket", webSocketEndpoint);

    registry.addHandler(new WebSocketServerHandler(), webSocketEndpoint).setAllowedOrigins("*");

    webSocketEndpoint = "/ws/header";
    logger.log(MessageType.DEBUG, "Registering WebSocket handler to {}", webSocketEndpoint);

    registry.addHandler(new HeaderSocketServerHandler(), webSocketEndpoint);
}