Example usage for org.springframework.web.socket.messaging SessionDisconnectEvent SessionDisconnectEvent

List of usage examples for org.springframework.web.socket.messaging SessionDisconnectEvent SessionDisconnectEvent

Introduction

In this page you can find the example usage for org.springframework.web.socket.messaging SessionDisconnectEvent SessionDisconnectEvent.

Prototype

public SessionDisconnectEvent(Object source, Message<byte[]> message, String sessionId, CloseStatus closeStatus,
        @Nullable Principal user) 

Source Link

Document

Create a new SessionDisconnectEvent.

Usage

From source file:org.springframework.web.socket.messaging.StompSubProtocolHandler.java

@Override
public void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) {
    this.decoders.remove(session.getId());

    Message<byte[]> message = createDisconnectMessage(session);
    SimpAttributes simpAttributes = SimpAttributes.fromMessage(message);
    try {//from w  w  w.  ja  va2 s .  c  o  m
        SimpAttributesContextHolder.setAttributes(simpAttributes);
        if (this.eventPublisher != null) {
            Principal user = getUser(session);
            publishEvent(this.eventPublisher,
                    new SessionDisconnectEvent(this, message, session.getId(), closeStatus, user));
        }
        outputChannel.send(message);
    } finally {
        this.stompAuthentications.remove(session.getId());
        SimpAttributesContextHolder.resetAttributes();
        simpAttributes.sessionCompleted();
    }
}