org.springframework.web.socket.config.annotation.StompEndpointRegistry Java Examples

The following examples show how to use org.springframework.web.socket.config.annotation.StompEndpointRegistry. 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 demo-projects with MIT License 6 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    /*
     * This configures a STOMP (Simple Text Oriented Messaging Protocol)
     * endpoint for our websocket to be hosted on
     */
    registry.addEndpoint("/websocket");
    /*
     * This configures an endpoint with a fallback for SockJS in case the
     * client (an old browser) doesn't support WebSockets natively
     */
    registry.addEndpoint("/sockjs")
            .withSockJS();
}
 
Example #2
Source File: WebSocketConfig.java    From spring-boot-start-current with Apache License 2.0 5 votes vote down vote up
/**
 * 配置端点注册中心,接收客户端的连接
 *
 * @param registry 端点注册中心
 */
@Override
public void registerStompEndpoints ( StompEndpointRegistry registry ) {
	/* 在指定的映射路径上为Web套接字端点注册一个STOMP. */
	// 表示添加了一个 /goblin 端点,客户端就可以通过这个端点来进行连接.
	// goblin
	registry.addEndpoint( stompEndpointsPaths )
			.withSockJS(); // 开启SockJS支持
}
 
Example #3
Source File: WebSocketStompClientIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void registerStompEndpoints(StompEndpointRegistry registry) {
	// Can't rely on classpath detection
	RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
	registry.addEndpoint("/stomp")
			.setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
			.setAllowedOrigins("*");
}
 
Example #4
Source File: WebSocketConfig.java    From spring-boot-demo with MIT License 5 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    // 注册一个 /notification 端点,前端通过这个端点进行连接
    registry.addEndpoint("/notification")
            //解决跨域问题
            .setAllowedOrigins("*")
            .withSockJS();
}
 
Example #5
Source File: WebSocketSendToUserConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/greeting").setHandshakeHandler(new DefaultHandshakeHandler() {

        //Get sessionId from request and set it in Map attributes
        public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
                                         Map attributes) throws Exception {
            if (request instanceof ServletServerHttpRequest) {
                ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
                HttpSession session = servletRequest.getServletRequest().getSession();
                attributes.put("sessionId", session.getId());
            }
            return true;
        }}).withSockJS();
}
 
Example #6
Source File: WebSocketConfig.java    From spring-boot-demo with MIT License 5 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    // 注册一个 /notification 端点,前端通过这个端点进行连接
    registry.addEndpoint("/notification")
            //解决跨域问题
            .setAllowedOrigins("*")
            .withSockJS();
}
 
Example #7
Source File: WebSocketConfig.java    From k8s-fleetman with MIT License 5 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry)
{
    registry.addEndpoint("/updates").setAllowedOrigins("*").withSockJS();
    registry.addEndpoint("/updates").setAllowedOrigins("*");
    
}
 
Example #8
Source File: WebSocketConfig.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void registerStompEndpoints(final StompEndpointRegistry registry)
{
	// the endpoint for websocket connections
	registry.addEndpoint(ENDPOINT)
			.setAllowedOrigins("*") // FIXME: for now we allow any origin
			.addInterceptors(new WebSocketHandshakeInterceptor())
			.withSockJS()
	//
	;
}
 
Example #9
Source File: WebSocketConfig.java    From youran with Apache License 2.0 5 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    // 注册websocket的url路径
    registry.addEndpoint(wsApiPath)
        .setAllowedOrigins("*")
        .withSockJS()
        .setInterceptors(httpSessionHandshakeInterceptor());;
}
 
Example #10
Source File: WebSocketMessageBrokerConfig.java    From springboot-learn with MIT License 5 votes vote down vote up
/**
 * 注册 Stomp的端点
 * addEndpoint:添加STOMP协议的端点。这个HTTP URL是供WebSocket或SockJS客户端访问的地址
 * setAllowedOrigins:添加允许跨域访问
 * withSockJS:指定端点使用SockJS协议
 */
@Override
public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
    stompEndpointRegistry.addEndpoint("/webSocket")
            .setAllowedOrigins("*")
            .withSockJS();
}
 
Example #11
Source File: WebsocketConfiguration.java    From TeamDojo with Apache License 2.0 5 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    String[] allowedOrigins = Optional.ofNullable(jHipsterProperties.getCors().getAllowedOrigins()).map(origins -> origins.toArray(new String[0])).orElse(new String[0]);
    registry.addEndpoint("/websocket/tracker")
        .setHandshakeHandler(defaultHandshakeHandler())
        .setAllowedOrigins(allowedOrigins)
        .withSockJS()
        .setInterceptors(httpSessionHandshakeInterceptor());
}
 
Example #12
Source File: ZuulWebSocketConfiguration.java    From spring-cloud-netflix-zuul-websocket with Apache License 2.0 5 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    boolean wsEnabled = false;
    for (Map.Entry<String, ZuulWebSocketProperties.WsBrokerage> entry : zuulWebSocketProperties
            .getBrokerages().entrySet()) {
        ZuulWebSocketProperties.WsBrokerage wsBrokerage = entry.getValue();
        if (wsBrokerage.isEnabled()) {
            this.addStompEndpoint(registry, wsBrokerage.getEndPoints());
            wsEnabled = true;
        }
    }

    if (!wsEnabled)
        this.addStompEndpoint(registry, UUID.randomUUID().toString());
}
 
Example #13
Source File: WebSocketConfig.java    From eventsourcing-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/subscribe").setAllowedOrigins("*");
    registry.addEndpoint("/subscribe").setAllowedOrigins("*").withSockJS();
}
 
Example #14
Source File: WebSocketConfig.java    From flowing-retail with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/gs-guide-websocket").withSockJS();
}
 
Example #15
Source File: WebSocketConfig.java    From spring-websocket-template with MIT License 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/handler").withSockJS();
}
 
Example #16
Source File: WebSocketConfig.java    From springboot-sockjs-stomp-vue-sample with MIT License 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/test-info").withSockJS();
}
 
Example #17
Source File: WebSocketConfig.java    From iot-traffic-monitor with Apache License 2.0 4 votes vote down vote up
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/stomp").withSockJS();
}
 
Example #18
Source File: AuthChannelInterceptorAdapterWebAppTest.java    From joal with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(final StompEndpointRegistry registry) {
    // Endpoints are already registered on WebSocketConfig, no need to add more.
}
 
Example #19
Source File: WebSocketConfig.java    From joal with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(final StompEndpointRegistry registry) {
    registry.addEndpoint(this.webSocketPathPrefix)
            .setAllowedOrigins("*");
}
 
Example #20
Source File: WebSecurityConfigWebAppTest.java    From joal with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(final StompEndpointRegistry registry) {
    registry.addEndpoint(TestConstant.UI_PATH_PREFIX).setAllowedOrigins("*");
}
 
Example #21
Source File: WebSocketConfig.java    From spring-boot-kafka-websocket with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
    // endPoint 注册协议节点,并映射指定的URl
    // 注册一个Stomp 协议的endpoint,并指定 SockJS协议。
    stompEndpointRegistry.addEndpoint("endpointWisely").withSockJS();
}
 
Example #22
Source File: WebSocketConfig.java    From DBus with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/projectTopologyOperate").setAllowedOrigins("*").withSockJS();
}
 
Example #23
Source File: TraceWebSocketAutoConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
	// The user must register their own endpoints
}
 
Example #24
Source File: WebSocketConfig.java    From servicecomb-pack with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
  registry.addEndpoint("/websocket-config").withSockJS();
}
 
Example #25
Source File: WebSocketConfig.java    From pro-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/stomp").withSockJS();
}
 
Example #26
Source File: WebSocketConfig.java    From flowing-retail-old with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/gs-guide-websocket").withSockJS();
}
 
Example #27
Source File: WebSocketConfig.java    From boot-actuator with MIT License 4 votes vote down vote up
/**
     * 注册协议节点,并映射指定的URl
     */
    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
//        registry.addEndpoint("/websocket").withSockJS();
        registry.addEndpoint("/websocket").setAllowedOrigins("*").withSockJS();
    }
 
Example #28
Source File: WebSocketConfig.java    From lambda-arch with Apache License 2.0 4 votes vote down vote up
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/stomp").withSockJS();
}
 
Example #29
Source File: Application.java    From boot-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/notifications").withSockJS();
}
 
Example #30
Source File: WebSocketConfig.java    From tutorial with MIT License 4 votes vote down vote up
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    //客户端new SockJS时需要这个地址;
    registry.addEndpoint("/socket/sample").withSockJS();
}