Search in sources :

Example 11 with SockJsHttpRequestHandler

use of org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler in project spring-framework by spring-projects.

the class ServletWebSocketHandlerRegistration method addSockJsServiceMapping.

@Override
protected void addSockJsServiceMapping(MultiValueMap<HttpRequestHandler, String> mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern) {
    SockJsHttpRequestHandler httpHandler = new SockJsHttpRequestHandler(sockJsService, handler);
    mappings.add(httpHandler, pathPattern);
}
Also used : SockJsHttpRequestHandler(org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler)

Example 12 with SockJsHttpRequestHandler

use of org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler in project spring-framework by spring-projects.

the class WebMvcStompWebSocketEndpointRegistration method getMappings.

public final MultiValueMap<HttpRequestHandler, String> getMappings() {
    MultiValueMap<HttpRequestHandler, String> mappings = new LinkedMultiValueMap<>();
    if (this.registration != null) {
        SockJsService sockJsService = this.registration.getSockJsService();
        for (String path : this.paths) {
            String pattern = (path.endsWith("/") ? path + "**" : path + "/**");
            SockJsHttpRequestHandler handler = new SockJsHttpRequestHandler(sockJsService, this.webSocketHandler);
            mappings.add(handler, pattern);
        }
    } else {
        for (String path : this.paths) {
            WebSocketHttpRequestHandler handler;
            if (this.handshakeHandler != null) {
                handler = new WebSocketHttpRequestHandler(this.webSocketHandler, this.handshakeHandler);
            } else {
                handler = new WebSocketHttpRequestHandler(this.webSocketHandler);
            }
            HandshakeInterceptor[] interceptors = getInterceptors();
            if (interceptors.length > 0) {
                handler.setHandshakeInterceptors(Arrays.asList(interceptors));
            }
            mappings.add(handler, path);
        }
    }
    return mappings;
}
Also used : SockJsHttpRequestHandler(org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler) WebSocketHttpRequestHandler(org.springframework.web.socket.server.support.WebSocketHttpRequestHandler) SockJsHttpRequestHandler(org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler) HttpRequestHandler(org.springframework.web.HttpRequestHandler) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) SockJsService(org.springframework.web.socket.sockjs.SockJsService) HandshakeInterceptor(org.springframework.web.socket.server.HandshakeInterceptor) OriginHandshakeInterceptor(org.springframework.web.socket.server.support.OriginHandshakeInterceptor) WebSocketHttpRequestHandler(org.springframework.web.socket.server.support.WebSocketHttpRequestHandler)

Aggregations

SockJsHttpRequestHandler (org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler)12 Test (org.junit.jupiter.api.Test)9 WebSocketHttpRequestHandler (org.springframework.web.socket.server.support.WebSocketHttpRequestHandler)9 HttpRequestHandler (org.springframework.web.HttpRequestHandler)8 DefaultSockJsService (org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService)8 SimpleUrlHandlerMapping (org.springframework.web.servlet.handler.SimpleUrlHandlerMapping)5 HandshakeInterceptor (org.springframework.web.socket.server.HandshakeInterceptor)4 OriginHandshakeInterceptor (org.springframework.web.socket.server.support.OriginHandshakeInterceptor)4 WebSocketTransportHandler (org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler)4 SockJsService (org.springframework.web.socket.sockjs.SockJsService)3 TransportHandler (org.springframework.web.socket.sockjs.transport.TransportHandler)3 TransportType (org.springframework.web.socket.sockjs.transport.TransportType)3 List (java.util.List)2 Map (java.util.Map)2 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)2 MessageHandler (org.springframework.messaging.MessageHandler)2 SimpAnnotationMethodMessageHandler (org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler)2 SimpleBrokerMessageHandler (org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler)2 StompBrokerRelayMessageHandler (org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler)2 DefaultUserDestinationResolver (org.springframework.messaging.simp.user.DefaultUserDestinationResolver)2