Package org.springframework.messaging.simp

Examples of org.springframework.messaging.simp.SimpAttributes


  @Test
  public void webSocketScope() {

    Runnable runnable = Mockito.mock(Runnable.class);
    SimpAttributes simpAttributes = new SimpAttributes(this.session.getId(), this.session.getAttributes());
    simpAttributes.setAttribute("name", "value");
    simpAttributes.registerDestructionCallback("name", runnable);

    MessageChannel testChannel = new MessageChannel() {
      @Override
      public boolean send(Message<?> message) {
        SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes();
        assertThat(simpAttributes.getAttribute("name"), is("value"));
        return true;
      }
      @Override
      public boolean send(Message<?> message, long timeout) {
        return false;
View Full Code Here


    else if (StompCommand.CONNECTED.equals(command)) {
      this.stats.incrementConnectedCount();
      stompAccessor = afterStompSessionConnected(message, stompAccessor, session);
      if (this.eventPublisher != null && StompCommand.CONNECTED.equals(command)) {
        try {
          SimpAttributes simpAttributes = new SimpAttributes(session.getId(), session.getAttributes());
          SimpAttributesContextHolder.setAttributes(simpAttributes);
          publishEvent(new SessionConnectedEvent(this, (Message<byte[]>) message));
        }
        finally {
          SimpAttributesContextHolder.resetAttributes();
View Full Code Here

    if (principal != null && this.userSessionRegistry != null) {
      String userName = getSessionRegistryUserName(principal);
      this.userSessionRegistry.unregisterSessionId(userName, session.getId());
    }
    Message<byte[]> message = createDisconnectMessage(session);
    SimpAttributes simpAttributes = SimpAttributes.fromMessage(message);
    try {
      SimpAttributesContextHolder.setAttributes(simpAttributes);
      if (this.eventPublisher != null) {
        publishEvent(new SessionDisconnectEvent(this, message, session.getId(), closeStatus));
      }
      outputChannel.send(message);
    }
    finally {
      SimpAttributesContextHolder.resetAttributes();
      simpAttributes.sessionCompleted();
    }
  }
View Full Code Here

      this.method = "handleValidationException";
    }

    @MessageMapping("/scope")
    public void scope() {
      SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes();
      assertThat(simpAttributes.getAttribute("name"), is("value"));
      this.method = "scope";
    }
View Full Code Here

TOP

Related Classes of org.springframework.messaging.simp.SimpAttributes

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.