Package org.springframework.messaging.simp.stomp

Examples of org.springframework.messaging.simp.stomp.StompEncoder


    this.protocolHandler.setApplicationEventPublisher(publisher);
    this.protocolHandler.afterSessionStarted(this.session, this.channel);

    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT);
    Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    TextMessage textMessage = new TextMessage(new StompEncoder().encode(message));
    this.protocolHandler.handleMessageFromClient(this.session, textMessage, this.channel);

    headers = StompHeaderAccessor.create(StompCommand.CONNECTED);
    message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    this.protocolHandler.handleMessageToClient(this.session, message);

    headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
    message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    textMessage = new TextMessage(new StompEncoder().encode(message));
    this.protocolHandler.handleMessageFromClient(this.session, textMessage, this.channel);

    headers = StompHeaderAccessor.create(StompCommand.UNSUBSCRIBE);
    message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    textMessage = new TextMessage(new StompEncoder().encode(message));
    this.protocolHandler.handleMessageFromClient(this.session, textMessage, this.channel);

    this.protocolHandler.afterSessionEnded(this.session, CloseStatus.BAD_DATA, this.channel);

    assertEquals("Unexpected events " + publisher.events, 5, publisher.events.size());
View Full Code Here


    this.protocolHandler.setApplicationEventPublisher(publisher);
    this.protocolHandler.afterSessionStarted(this.session, this.channel);

    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT);
    Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    TextMessage textMessage = new TextMessage(new StompEncoder().encode(message));
    this.protocolHandler.handleMessageFromClient(this.session, textMessage, this.channel);

    verify(this.channel).send(this.messageCaptor.capture());
    Message<?> actual = this.messageCaptor.getValue();
    assertNotNull(actual);
View Full Code Here

    this.protocolHandler.afterSessionStarted(this.session, this.channel);

    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT);
    Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    TextMessage textMessage = new TextMessage(new StompEncoder().encode(message));

    this.protocolHandler.handleMessageFromClient(this.session, textMessage, testChannel);
    assertEquals(Collections.emptyList(), session.getSentMessages());

    this.protocolHandler.afterSessionEnded(this.session, CloseStatus.BAD_DATA, testChannel);
View Full Code Here

  public void connectReceiveAndCloseWithStompFrame() throws Exception {
    StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SEND);
    accessor.setDestination("/destination");
    MessageHeaders headers = accessor.getMessageHeaders();
    Message<byte[]> message = MessageBuilder.createMessage("body".getBytes(Charset.forName("UTF-8")), headers);
    byte[] bytes = new StompEncoder().encode(message);
    TextMessage textMessage = new TextMessage(bytes);
    SockJsFrame frame = SockJsFrame.messageFrame(new Jackson2SockJsMessageCodec(), textMessage.getPayload());

    String body = "o\n" + frame.getContent() + "\n" + "c[3000,\"Go away!\"]";
    ClientHttpResponse response = response(HttpStatus.OK, body);
View Full Code Here

TOP

Related Classes of org.springframework.messaging.simp.stomp.StompEncoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.