当前位置: 首页>>代码示例>>Java>>正文


Java DefaultHandshakeHandler类代码示例

本文整理汇总了Java中org.springframework.web.socket.server.support.DefaultHandshakeHandler的典型用法代码示例。如果您正苦于以下问题:Java DefaultHandshakeHandler类的具体用法?Java DefaultHandshakeHandler怎么用?Java DefaultHandshakeHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultHandshakeHandler类属于org.springframework.web.socket.server.support包,在下文中一共展示了DefaultHandshakeHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerWebSocketHandlers

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER);
    policy.setMaxTextMessageBufferSize(MAX_MSG_SIZE);
    policy.setMaxTextMessageSize(MAX_MSG_SIZE);
    policy.setIdleTimeout(IDLE_TIMEOUT);

    OcppWebSocketUpgrader upgradeStrategy = new OcppWebSocketUpgrader(
            policy, ocpp12WebSocketEndpoint, ocpp15WebSocketEndpoint, chargePointRepository);

    DefaultHandshakeHandler handler = new DefaultHandshakeHandler(upgradeStrategy);
    handler.setSupportedProtocols(PROTOCOLS);

    registry.addHandler(ocpp12WebSocketEndpoint, "/websocket/CentralSystemService/*")
            .addHandler(ocpp15WebSocketEndpoint, "/websocket/CentralSystemService/*")
            .setHandshakeHandler(handler)
            .setAllowedOrigins("*");
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:19,代码来源:WebSocketConfiguration.java

示例2: getDefaultTransportHandlers

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
private static Set<TransportHandler> getDefaultTransportHandlers(Collection<TransportHandler> overrides) {
	Set<TransportHandler> result = new LinkedHashSet<TransportHandler>(8);
	result.add(new XhrPollingTransportHandler());
	result.add(new XhrReceivingTransportHandler());
	result.add(new XhrStreamingTransportHandler());
	result.add(new JsonpPollingTransportHandler());
	result.add(new JsonpReceivingTransportHandler());
	result.add(new EventSourceTransportHandler());
	result.add(new HtmlFileTransportHandler());
	try {
		result.add(new WebSocketTransportHandler(new DefaultHandshakeHandler()));
	}
	catch (Exception ex) {
		Log logger = LogFactory.getLog(DefaultSockJsService.class);
		if (logger.isWarnEnabled()) {
			logger.warn("Failed to create a default WebSocketTransportHandler", ex);
		}
	}
	if (overrides != null) {
		result.addAll(overrides);
	}
	return result;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:DefaultSockJsService.java

示例3: handshakeHandlerPassedToSockJsRegistration

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Test
public void handshakeHandlerPassedToSockJsRegistration() {
	WebSocketHandler handler = new TextWebSocketHandler();
	HandshakeHandler handshakeHandler = new DefaultHandshakeHandler();

	this.registration.addHandler(handler, "/foo").setHandshakeHandler(handshakeHandler).withSockJS();

	List<Mapping> mappings = this.registration.getMappings();
	assertEquals(1, mappings.size());

	Mapping mapping = mappings.get(0);
	assertEquals(handler, mapping.webSocketHandler);
	assertEquals("/foo/**", mapping.path);
	assertNotNull(mapping.sockJsService);

	WebSocketTransportHandler transportHandler =
			(WebSocketTransportHandler) mapping.sockJsService.getTransportHandlers().get(TransportType.WEBSOCKET);
	assertSame(handshakeHandler, transportHandler.getHandshakeHandler());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:WebSocketHandlerRegistrationTests.java

示例4: handshakeHandlerAndInterceptor

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Test
public void handshakeHandlerAndInterceptor() {
	WebMvcStompWebSocketEndpointRegistration registration =
			new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);

	DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
	HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();

	registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor);

	MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
	assertEquals(1, mappings.size());

	Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
	assertEquals(Arrays.asList("/foo"), entry.getValue());

	WebSocketHttpRequestHandler requestHandler = (WebSocketHttpRequestHandler) entry.getKey();
	assertNotNull(requestHandler.getWebSocketHandler());
	assertSame(handshakeHandler, requestHandler.getHandshakeHandler());
	assertEquals(2, requestHandler.getHandshakeInterceptors().size());
	assertEquals(interceptor, requestHandler.getHandshakeInterceptors().get(0));
	assertEquals(OriginHandshakeInterceptor.class, requestHandler.getHandshakeInterceptors().get(1).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java

示例5: handshakeHandlerAndInterceptorWithAllowedOrigins

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Test
public void handshakeHandlerAndInterceptorWithAllowedOrigins() {
	WebMvcStompWebSocketEndpointRegistration registration =
			new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);

	DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
	HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
	String origin = "http://mydomain.com";
	registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).setAllowedOrigins(origin);

	MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
	assertEquals(1, mappings.size());

	Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
	assertEquals(Arrays.asList("/foo"), entry.getValue());

	WebSocketHttpRequestHandler requestHandler = (WebSocketHttpRequestHandler) entry.getKey();
	assertNotNull(requestHandler.getWebSocketHandler());
	assertSame(handshakeHandler, requestHandler.getHandshakeHandler());
	assertEquals(2, requestHandler.getHandshakeInterceptors().size());
	assertEquals(interceptor, requestHandler.getHandshakeInterceptors().get(0));
	assertEquals(OriginHandshakeInterceptor.class, requestHandler.getHandshakeInterceptors().get(1).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java

示例6: registerStompEndpoints

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Override
protected void registerStompEndpoints(StompEndpointRegistry registry) {
	// Can't rely on classpath detection
	RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
	registry.addEndpoint("/stomp")
			.setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
			.setAllowedOrigins("*");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:WebSocketStompClientIntegrationTests.java

示例7: registerWebSocketHandlers

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER);
    policy.setMaxTextMessageBufferSize(MAX_MSG_SIZE);
    policy.setMaxTextMessageSize(MAX_MSG_SIZE);
    policy.setIdleTimeout(IDLE_TIMEOUT);

    OcppWebSocketUpgrader upgradeStrategy = new OcppWebSocketUpgrader(
            policy, ocpp12WebSocketEndpoint, ocpp15WebSocketEndpoint, chargePointRepository, notificationService);

    DefaultHandshakeHandler handler = new DefaultHandshakeHandler(upgradeStrategy);
    handler.setSupportedProtocols(PROTOCOLS);

    registry.addHandler(ocpp12WebSocketEndpoint, "/websocket/CentralSystemService/*")
            .addHandler(ocpp15WebSocketEndpoint, "/websocket/CentralSystemService/*")
            .setHandshakeHandler(handler)
            .setAllowedOrigins("*");
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve,代码行数:19,代码来源:WebSocketConfiguration.java

示例8: handshakeHandlerInterceptorWithSockJsService

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Test
public void handshakeHandlerInterceptorWithSockJsService() {
	WebMvcStompWebSocketEndpointRegistration registration =
			new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);

	DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
	HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();

	registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).withSockJS();

	MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
	assertEquals(1, mappings.size());

	Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
	assertEquals(Arrays.asList("/foo/**"), entry.getValue());

	SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey();
	assertNotNull(requestHandler.getWebSocketHandler());

	DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService();
	assertNotNull(sockJsService);

	Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers();
	WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET);
	assertSame(handshakeHandler, transportHandler.getHandshakeHandler());
	assertEquals(2, sockJsService.getHandshakeInterceptors().size());
	assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0));
	assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java

示例9: handshakeHandlerInterceptorWithSockJsServiceAndAllowedOrigins

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Test
public void handshakeHandlerInterceptorWithSockJsServiceAndAllowedOrigins() {
	WebMvcStompWebSocketEndpointRegistration registration =
			new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);

	DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
	HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
	String origin = "http://mydomain.com";

	registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).setAllowedOrigins(origin).withSockJS();

	MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
	assertEquals(1, mappings.size());

	Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
	assertEquals(Arrays.asList("/foo/**"), entry.getValue());

	SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey();
	assertNotNull(requestHandler.getWebSocketHandler());

	DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService();
	assertNotNull(sockJsService);

	Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers();
	WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET);
	assertSame(handshakeHandler, transportHandler.getHandshakeHandler());
	assertEquals(2, sockJsService.getHandshakeInterceptors().size());
	assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0));
	assertEquals(OriginHandshakeInterceptor.class,
			sockJsService.getHandshakeInterceptors().get(1).getClass());
	assertTrue(sockJsService.getAllowedOrigins().contains(origin));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:33,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java

示例10: registerStompEndpoints

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Override
protected void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
    stompEndpointRegistry.addEndpoint(SdcctWebSocketPaths.TESTCASES_IHE_RESULTS)
        .setHandshakeHandler(new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy())).addInterceptors(new HttpSessionHandshakeInterceptor())
        .withSockJS().setClientLibraryUrl(this.sockJsClientLibUrl).setDisconnectDelay(this.sockJsDisconnectDelay).setHeartbeatTime(this.sockJsHeartbeatTime)
        .setHttpMessageCacheSize(this.sockJsHttpMsgCacheSize).setMessageCodec(new Jackson2SockJsMessageCodec(this.objMapper))
        .setStreamBytesLimit(this.sockJsStreamLimit);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:9,代码来源:SdcctWebSocketMessageBrokerConfiguration.java

示例11: getOrCreateHandshakeHandler

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
private HandshakeHandler getOrCreateHandshakeHandler() {
	return (this.handshakeHandler != null) ? this.handshakeHandler : new DefaultHandshakeHandler();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:AbstractWebSocketHandlerRegistration.java

示例12: handshakeHandler

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Bean
public DefaultHandshakeHandler handshakeHandler() {
	return new DefaultHandshakeHandler(requestUpgradeStrategy());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:AbstractWebSocketIntegrationTests.java

示例13: setup

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Before
public void setup() throws Exception {
	MockitoAnnotations.initMocks(this);
	this.handshakeHandler = new DefaultHandshakeHandler(this.upgradeStrategy);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:DefaultHandshakeHandlerTests.java

示例14: registerWebSocketHandlers

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
	HandshakeHandler handshakeHandler = new DefaultHandshakeHandler(this.upgradeStrategy);
	registry.addHandler(new EchoHandler(), "/echo").setHandshakeHandler(handshakeHandler).withSockJS();
	registry.addHandler(testServerHandler(), "/test").setHandshakeHandler(handshakeHandler).withSockJS();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:AbstractSockJsIntegrationTests.java

示例15: handshakeHandler

import org.springframework.web.socket.server.support.DefaultHandshakeHandler; //导入依赖的package包/类
@Bean
public DefaultHandshakeHandler handshakeHandler() {
    return new AnonymousUsersHandshakeHandler();
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:5,代码来源:WebSocketConfig.java


注:本文中的org.springframework.web.socket.server.support.DefaultHandshakeHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。