本文整理汇总了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();
}
示例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());
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}