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


Java AbstractWebSocketHandler类代码示例

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


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

示例1: main

import org.springframework.web.socket.handler.AbstractWebSocketHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    WebSocketClient client = new StandardWebSocketClient();
    String url = "ws://localhost:8081/socket";
    ListenableFuture<WebSocketSession> future = client.doHandshake(new AbstractWebSocketHandler() {
        @Override
        public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
            System.out.println(message.getPayload());
        }
    }, url);

    WebSocketSession socketSession = future.get();
    socketSession.sendMessage(new TextMessage("{\"command\":\"test\",\"parameters\":{\"type\":\"conn\"}}"));

    System.in.read();
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:16,代码来源:WebSocketClientTests.java

示例2: unsolicitedPongWithEmptyPayload

import org.springframework.web.socket.handler.AbstractWebSocketHandler; //导入依赖的package包/类
@Test
public void unsolicitedPongWithEmptyPayload() throws Exception {

	String url = getWsBaseUrl() + "/ws";
	WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get();

	TestWebSocketHandler serverHandler = this.wac.getBean(TestWebSocketHandler.class);
	serverHandler.setWaitMessageCount(1);

	session.sendMessage(new PongMessage());

	serverHandler.await();
	assertNull(serverHandler.getTransportError());
	assertEquals(1, serverHandler.getReceivedMessages().size());
	assertEquals(PongMessage.class, serverHandler.getReceivedMessages().get(0).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:WebSocketIntegrationTests.java

示例3: setup

import org.springframework.web.socket.handler.AbstractWebSocketHandler; //导入依赖的package包/类
@Before
public void setup() {
	this.headers = new WebSocketHttpHeaders();
	this.wsHandler = new AbstractWebSocketHandler() {
	};
	this.wsContainer = mock(WebSocketContainer.class);
	this.wsClient = new StandardWebSocketClient(this.wsContainer);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:StandardWebSocketClientTests.java

示例4: registerWebSocketHandler

import org.springframework.web.socket.handler.AbstractWebSocketHandler; //导入依赖的package包/类
@Test
public void registerWebSocketHandler() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/ws").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:WebSocketConfigurationTests.java

示例5: registerWebSocketHandlerWithSockJS

import org.springframework.web.socket.handler.AbstractWebSocketHandler; //导入依赖的package包/类
@Test
public void registerWebSocketHandlerWithSockJS() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/sockjs/websocket").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:WebSocketConfigurationTests.java

示例6: startWebSocketSession

import org.springframework.web.socket.handler.AbstractWebSocketHandler; //导入依赖的package包/类
protected WebSocketSession startWebSocketSession(AbstractWebSocketHandler result,
		DataFormat dataFormat) throws InterruptedException, ExecutionException {
	WebSocketClient webSocketClient = new StandardWebSocketClient();
	return webSocketClient
			.doHandshake(result, getHeaders(dataFormat), wampEndpointUrl()).get();
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:7,代码来源:BaseWampTest.java

示例7: startWebSocketSession

import org.springframework.web.socket.handler.AbstractWebSocketHandler; //导入依赖的package包/类
protected WebSocketSession startWebSocketSession(AbstractWebSocketHandler result)
		throws InterruptedException, ExecutionException {
	WebSocketClient webSocketClient = createWebSocketClient();
	return webSocketClient.doHandshake(result, wampEndpointUrl()).get();
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:6,代码来源:BaseWampTest.java


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