本文整理汇总了Java中org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter类的典型用法代码示例。如果您正苦于以下问题:Java StompSessionHandlerAdapter类的具体用法?Java StompSessionHandlerAdapter怎么用?Java StompSessionHandlerAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StompSessionHandlerAdapter类属于org.springframework.messaging.simp.stomp包,在下文中一共展示了StompSessionHandlerAdapter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTracedWebsocketSession
import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter; //导入依赖的package包/类
@Test
public void testTracedWebsocketSession()
throws URISyntaxException, InterruptedException, ExecutionException, TimeoutException {
WebSocketStompClient stompClient = new WebSocketStompClient(
new SockJsClient(createTransportClient()));
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
StompSession stompSession = stompClient.connect(url, new StompSessionHandlerAdapter() {
}).get(1, TimeUnit.SECONDS);
stompSession.subscribe(SUBSCRIBE_GREETINGS_ENDPOINT, new GreetingStompFrameHandler());
stompSession.send(SEND_HELLO_MESSAGE_ENDPOINT, new HelloMessage("Hi"));
// Three spans related to the websocket session, and two related to websocket connect
await().until(() -> mockTracer.finishedSpans().size() == 5);
assertTrue(mockTracer.finishedSpans().stream().filter(s ->
s.operationName().equals(SEND_HELLO_MESSAGE_ENDPOINT)).toArray().length == 1);
assertTrue(mockTracer.finishedSpans().stream().filter(s ->
s.operationName().equals(SUBSCRIBE_GREETINGS_ENDPOINT)).toArray().length == 1);
assertTrue(mockTracer.finishedSpans().stream().filter(s ->
s.operationName().equals(GreetingController.DOING_WORK)).toArray().length == 1);
}
示例2: testConnect
import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter; //导入依赖的package包/类
@Test
public void testConnect() throws Exception {
try {
StompSession stompSession = stompClient.connect("ws://localhost:" + port + "/notifications", webSocketHttpHeaders, new StompSessionHandlerAdapter() {
}).get();
} catch (RuntimeException e) {
fail("Could not connect to endpoint notifications. " + e.getMessage());
}
}