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


Java StompSessionHandlerAdapter类代码示例

本文整理汇总了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);
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-cloud,代码行数:24,代码来源:SpringWebsocketTracingTest.java

示例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());
  }
}
 
开发者ID:sys-devel-d,项目名称:pimp,代码行数:10,代码来源:NotificationControllerIT.java


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