org.springframework.web.socket.messaging.StompSubProtocolHandler Java Examples
The following examples show how to use
org.springframework.web.socket.messaging.StompSubProtocolHandler.
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: WebMvcStompEndpointRegistry.java From spring-analysis-note with MIT License | 6 votes |
public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler, WebSocketTransportRegistration transportRegistration, TaskScheduler defaultSockJsTaskScheduler) { Assert.notNull(webSocketHandler, "WebSocketHandler is required "); Assert.notNull(transportRegistration, "WebSocketTransportRegistration is required"); this.webSocketHandler = webSocketHandler; this.subProtocolWebSocketHandler = unwrapSubProtocolWebSocketHandler(webSocketHandler); if (transportRegistration.getSendTimeLimit() != null) { this.subProtocolWebSocketHandler.setSendTimeLimit(transportRegistration.getSendTimeLimit()); } if (transportRegistration.getSendBufferSizeLimit() != null) { this.subProtocolWebSocketHandler.setSendBufferSizeLimit(transportRegistration.getSendBufferSizeLimit()); } if (transportRegistration.getTimeToFirstMessage() != null) { this.subProtocolWebSocketHandler.setTimeToFirstMessage(transportRegistration.getTimeToFirstMessage()); } this.stompHandler = new StompSubProtocolHandler(); if (transportRegistration.getMessageSizeLimit() != null) { this.stompHandler.setMessageSizeLimit(transportRegistration.getMessageSizeLimit()); } this.sockJsScheduler = defaultSockJsTaskScheduler; }
Example #2
Source File: WebSocketMessageBrokerStats.java From spring-analysis-note with MIT License | 6 votes |
@Nullable private StompSubProtocolHandler initStompSubProtocolHandler() { if (this.webSocketHandler == null) { return null; } for (SubProtocolHandler handler : this.webSocketHandler.getProtocolHandlers()) { if (handler instanceof StompSubProtocolHandler) { return (StompSubProtocolHandler) handler; } } SubProtocolHandler defaultHandler = this.webSocketHandler.getDefaultProtocolHandler(); if (defaultHandler != null && defaultHandler instanceof StompSubProtocolHandler) { return (StompSubProtocolHandler) defaultHandler; } return null; }
Example #3
Source File: WebMvcStompEndpointRegistry.java From java-technology-stack with MIT License | 6 votes |
public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler, WebSocketTransportRegistration transportRegistration, TaskScheduler defaultSockJsTaskScheduler) { Assert.notNull(webSocketHandler, "WebSocketHandler is required "); Assert.notNull(transportRegistration, "WebSocketTransportRegistration is required"); this.webSocketHandler = webSocketHandler; this.subProtocolWebSocketHandler = unwrapSubProtocolWebSocketHandler(webSocketHandler); if (transportRegistration.getSendTimeLimit() != null) { this.subProtocolWebSocketHandler.setSendTimeLimit(transportRegistration.getSendTimeLimit()); } if (transportRegistration.getSendBufferSizeLimit() != null) { this.subProtocolWebSocketHandler.setSendBufferSizeLimit(transportRegistration.getSendBufferSizeLimit()); } if (transportRegistration.getTimeToFirstMessage() != null) { this.subProtocolWebSocketHandler.setTimeToFirstMessage(transportRegistration.getTimeToFirstMessage()); } this.stompHandler = new StompSubProtocolHandler(); if (transportRegistration.getMessageSizeLimit() != null) { this.stompHandler.setMessageSizeLimit(transportRegistration.getMessageSizeLimit()); } this.sockJsScheduler = defaultSockJsTaskScheduler; }
Example #4
Source File: WebSocketMessageBrokerStats.java From java-technology-stack with MIT License | 6 votes |
@Nullable private StompSubProtocolHandler initStompSubProtocolHandler() { if (this.webSocketHandler == null) { return null; } for (SubProtocolHandler handler : this.webSocketHandler.getProtocolHandlers()) { if (handler instanceof StompSubProtocolHandler) { return (StompSubProtocolHandler) handler; } } SubProtocolHandler defaultHandler = this.webSocketHandler.getDefaultProtocolHandler(); if (defaultHandler != null && defaultHandler instanceof StompSubProtocolHandler) { return (StompSubProtocolHandler) defaultHandler; } return null; }
Example #5
Source File: SockJsWebSocketHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void getSubProtocols() throws Exception { SubscribableChannel channel = mock(SubscribableChannel.class); SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel); StompSubProtocolHandler stompHandler = new StompSubProtocolHandler(); handler.addProtocolHandler(stompHandler); TaskScheduler scheduler = mock(TaskScheduler.class); DefaultSockJsService service = new DefaultSockJsService(scheduler); WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null); SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session); assertEquals(stompHandler.getSupportedProtocols(), sockJsHandler.getSubProtocols()); }
Example #6
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void webSocketHandler() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); SubProtocolWebSocketHandler subWsHandler = config.getBean(SubProtocolWebSocketHandler.class); assertEquals(1024 * 1024, subWsHandler.getSendBufferSizeLimit()); assertEquals(25 * 1000, subWsHandler.getSendTimeLimit()); assertEquals(30 * 1000, subWsHandler.getTimeToFirstMessage()); Map<String, SubProtocolHandler> handlerMap = subWsHandler.getProtocolHandlerMap(); StompSubProtocolHandler protocolHandler = (StompSubProtocolHandler) handlerMap.get("v12.stomp"); assertEquals(128 * 1024, protocolHandler.getMessageSizeLimit()); }
Example #7
Source File: SockJsWebSocketHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void getSubProtocols() throws Exception { SubscribableChannel channel = mock(SubscribableChannel.class); SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel); StompSubProtocolHandler stompHandler = new StompSubProtocolHandler(); handler.addProtocolHandler(stompHandler); TaskScheduler scheduler = mock(TaskScheduler.class); DefaultSockJsService service = new DefaultSockJsService(scheduler); WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null); SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session); assertEquals(stompHandler.getSupportedProtocols(), sockJsHandler.getSubProtocols()); }
Example #8
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void webSocketHandler() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); SubProtocolWebSocketHandler subWsHandler = config.getBean(SubProtocolWebSocketHandler.class); assertEquals(1024 * 1024, subWsHandler.getSendBufferSizeLimit()); assertEquals(25 * 1000, subWsHandler.getSendTimeLimit()); assertEquals(30 * 1000, subWsHandler.getTimeToFirstMessage()); Map<String, SubProtocolHandler> handlerMap = subWsHandler.getProtocolHandlerMap(); StompSubProtocolHandler protocolHandler = (StompSubProtocolHandler) handlerMap.get("v12.stomp"); assertEquals(128 * 1024, protocolHandler.getMessageSizeLimit()); }
Example #9
Source File: WebMvcStompEndpointRegistry.java From spring4-understanding with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler, WebSocketTransportRegistration transportRegistration, org.springframework.messaging.simp.user.UserSessionRegistry userSessionRegistry, TaskScheduler defaultSockJsTaskScheduler) { Assert.notNull(webSocketHandler, "'webSocketHandler' is required "); Assert.notNull(transportRegistration, "'transportRegistration' is required"); this.webSocketHandler = webSocketHandler; this.subProtocolWebSocketHandler = unwrapSubProtocolWebSocketHandler(webSocketHandler); if (transportRegistration.getSendTimeLimit() != null) { this.subProtocolWebSocketHandler.setSendTimeLimit(transportRegistration.getSendTimeLimit()); } if (transportRegistration.getSendBufferSizeLimit() != null) { this.subProtocolWebSocketHandler.setSendBufferSizeLimit(transportRegistration.getSendBufferSizeLimit()); } this.stompHandler = new StompSubProtocolHandler(); this.stompHandler.setUserSessionRegistry(userSessionRegistry); if (transportRegistration.getMessageSizeLimit() != null) { this.stompHandler.setMessageSizeLimit(transportRegistration.getMessageSizeLimit()); } this.sockJsScheduler = defaultSockJsTaskScheduler; }
Example #10
Source File: WebSocketMessageBrokerStats.java From spring4-understanding with Apache License 2.0 | 5 votes |
private StompSubProtocolHandler initStompSubProtocolHandler() { for (SubProtocolHandler handler : this.webSocketHandler.getProtocolHandlers()) { if (handler instanceof StompSubProtocolHandler) { return (StompSubProtocolHandler) handler; } } SubProtocolHandler defaultHandler = this.webSocketHandler.getDefaultProtocolHandler(); if (defaultHandler != null && defaultHandler instanceof StompSubProtocolHandler) { return (StompSubProtocolHandler) defaultHandler; } return null; }
Example #11
Source File: SockJsWebSocketHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void getSubProtocols() throws Exception { SubscribableChannel channel = mock(SubscribableChannel.class); SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel); StompSubProtocolHandler stompHandler = new StompSubProtocolHandler(); handler.addProtocolHandler(stompHandler); TaskScheduler scheduler = mock(TaskScheduler.class); DefaultSockJsService service = new DefaultSockJsService(scheduler); WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null); SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session); assertEquals(stompHandler.getSupportedProtocols(), sockJsHandler.getSubProtocols()); }
Example #12
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void webSocketHandler() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); SubProtocolWebSocketHandler subWsHandler = config.getBean(SubProtocolWebSocketHandler.class); assertEquals(1024 * 1024, subWsHandler.getSendBufferSizeLimit()); assertEquals(25 * 1000, subWsHandler.getSendTimeLimit()); Map<String, SubProtocolHandler> handlerMap = subWsHandler.getProtocolHandlerMap(); StompSubProtocolHandler protocolHandler = (StompSubProtocolHandler) handlerMap.get("v12.stomp"); assertEquals(128 * 1024, protocolHandler.getMessageSizeLimit()); }