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


Java StompSession类代码示例

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


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

示例1: testTracedWebsocketSession

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的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: afterConnected

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Override
public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
    session.subscribe("/topic/greetings", this);
    session.send("/app/hello", "{\"name\":\"Client\"}".getBytes());

    log.info("New session: {}", session.getSessionId());
}
 
开发者ID:nielsutrecht,项目名称:spring-boot-websocket-client,代码行数:8,代码来源:MySessionHandler.java

示例3: postProcessAfterInitialization

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
    if (bean instanceof StompSession && !(bean instanceof PreservesHeadersStompSessionAdapter)) {
        if (propagationProperties.getStomp().accept(beanName)) {
            log.info("Context propagation enabled for stomp session [{}] on keys={}.", beanName, propagationProperties.getKeys());
            return new PreservesHeadersStompSessionAdapter((StompSession) bean,
                    propagationProperties.buildEntriesFilter(),
                    propagationProperties.buildExtraStaticEntries(eurekaInstanceProperties));
        } else {
            log.debug("Context propagation disabled for stomp session [{}]", beanName);
        }
    }
    return bean;
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:18,代码来源:PreservesStompHeadersStrategy.java

示例4: should_skip_stomp_session

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Test
public void should_skip_stomp_session() {
    PropagationProperties propagationProperties = new PropagationProperties();
    propagationProperties.getStomp().getExcludes().add(compile(beanName));
    processor.setPropagationProperties(propagationProperties);
    processor.setEurekaInstanceProperties(new EurekaInstanceProperties());
    assertThat(processor.postProcessAfterInitialization(mock(StompSession.class), beanName).getClass(), not(equalTo(PreservesHeadersStompSessionAdapter.class)));
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:9,代码来源:PreservesStompHeadersStrategyTest.java

示例5: afterConnected

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Override
public void afterConnected(StompSession session,
			   StompHeaders connectedHeaders)
{
    System.err.println("Connected! Headers:");
    showHeaders(connectedHeaders);

    subscribeTopic("/topic/messages", session);
    sendJsonMessage(session);
}
 
开发者ID:jaysridhar,项目名称:spring-websocket-client,代码行数:11,代码来源:Application.java

示例6: main

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
public static void main(String args[]) throws Exception
   {
WebSocketClient simpleWebSocketClient =
    new StandardWebSocketClient();
List<Transport> transports = new ArrayList<>(1);
transports.add(new WebSocketTransport(simpleWebSocketClient));

SockJsClient sockJsClient = new SockJsClient(transports);
WebSocketStompClient stompClient =
    new WebSocketStompClient(sockJsClient);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());

String url = "ws://localhost:9090/chat";
String userId = "spring-" +
    ThreadLocalRandom.current().nextInt(1, 99);
StompSessionHandler sessionHandler = new MyStompSessionHandler(userId);
StompSession session = stompClient.connect(url, sessionHandler)
    .get();
BufferedReader in =
    new BufferedReader(new InputStreamReader(System.in));
for (;;) {
    System.out.print(userId + " >> ");
    System.out.flush();
    String line = in.readLine();
    if ( line == null ) break;
    if ( line.length() == 0 ) continue;
    ClientMessage msg = new ClientMessage(userId, line);
    session.send("/app/chat/java", msg);
}
   }
 
开发者ID:jaysridhar,项目名称:spring-websocket-client,代码行数:31,代码来源:Application.java

示例7: handleException

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Override
public void handleException(StompSession session, StompCommand command,
		StompHeaders headers, byte[] payload, Throwable ex) {
	if (errorHandler != null) {
		errorHandler.handleError(new ProxySessionException(this, session, ex));
	}
}
 
开发者ID:mthizo247,项目名称:spring-cloud-netflix-zuul-websocket,代码行数:8,代码来源:ProxyWebSocketConnectionManager.java

示例8: unsubscribe

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
public void unsubscribe(String destination) {
	StompSession.Subscription subscription = subscriptions.remove(destination);
	if (subscription != null) {
		connectIfNecessary();
		subscription.unsubscribe();
	}
}
 
开发者ID:mthizo247,项目名称:spring-cloud-netflix-zuul-websocket,代码行数:8,代码来源:ProxyWebSocketConnectionManager.java

示例9: testConnect

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的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

示例10: handleException

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Override
public void handleException(StompSession session, StompCommand command, StompHeaders headers, byte[] payload, Throwable exception) {
    exception.printStackTrace();
}
 
开发者ID:nielsutrecht,项目名称:spring-boot-websocket-client,代码行数:5,代码来源:MySessionHandler.java

示例11: should_decorate_stomp_session

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Test
public void should_decorate_stomp_session() {
    processor.setPropagationProperties(new PropagationProperties());
    processor.setEurekaInstanceProperties(new EurekaInstanceProperties());
    assertThat(processor.postProcessAfterInitialization(mock(StompSession.class), beanName).getClass(), equalTo(PreservesHeadersStompSessionAdapter.class));
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:7,代码来源:PreservesStompHeadersStrategyTest.java

示例12: handleException

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Override
public void handleException(StompSession s, StompCommand c, StompHeaders h, byte[] p, Throwable ex) {
    this.failure.set(ex);
}
 
开发者ID:sweetca,项目名称:logger,代码行数:5,代码来源:LogIntegrationTests.java

示例13: handleTransportError

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Override
public void handleTransportError(StompSession session, Throwable ex) {
    this.failure.set(ex);
}
 
开发者ID:sweetca,项目名称:logger,代码行数:5,代码来源:LogIntegrationTests.java

示例14: sendJsonMessage

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
private void sendJsonMessage(StompSession session)
{
    ClientMessage msg = new ClientMessage(userId,
					  "hello from spring");
    session.send("/app/chat/java", msg);
}
 
开发者ID:jaysridhar,项目名称:spring-websocket-client,代码行数:7,代码来源:Application.java

示例15: handleException

import org.springframework.messaging.simp.stomp.StompSession; //导入依赖的package包/类
@Override
public void handleException(StompSession s, StompCommand c, StompHeaders h, byte[] p, Throwable ex) {
	this.failure.set(ex);
}
 
开发者ID:WASdev,项目名称:sample.SpringBootWebsocket,代码行数:5,代码来源:GreetingIntegrationTestIT.java


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