Update SessionDisconnectEvent
SessionDisconnectEvent now extends AbstractSubProtocolEvent. Issue: SPR-12156
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package org.springframework.web.socket.messaging;
|
||||
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
|
||||
@@ -32,21 +32,18 @@ import org.springframework.web.socket.CloseStatus;
|
||||
* @since 4.0.3
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SessionDisconnectEvent extends ApplicationEvent {
|
||||
public class SessionDisconnectEvent extends AbstractSubProtocolEvent {
|
||||
|
||||
private final String sessionId;
|
||||
|
||||
private final CloseStatus status;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new event.
|
||||
*
|
||||
* @param source the component that published the event (never {@code null})
|
||||
* @param sessionId the disconnect message
|
||||
* @param closeStatus
|
||||
*/
|
||||
public SessionDisconnectEvent(Object source, String sessionId, CloseStatus closeStatus) {
|
||||
super(source);
|
||||
public SessionDisconnectEvent(Object source, Message<byte[]> message, String sessionId, CloseStatus closeStatus) {
|
||||
super(source, message);
|
||||
Assert.notNull(sessionId, "'sessionId' must not be null");
|
||||
this.sessionId = sessionId;
|
||||
this.status = closeStatus;
|
||||
|
||||
@@ -447,10 +447,10 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||
String userName = getSessionRegistryUserName(principal);
|
||||
this.userSessionRegistry.unregisterSessionId(userName, session.getId());
|
||||
}
|
||||
Message<byte[]> message = createDisconnectMessage(session);
|
||||
if (this.eventPublisher != null) {
|
||||
publishEvent(new SessionDisconnectEvent(this, session.getId(), closeStatus));
|
||||
publishEvent(new SessionDisconnectEvent(this, message, session.getId(), closeStatus));
|
||||
}
|
||||
Message<?> message = createDisconnectMessage(session);
|
||||
SimpAttributes simpAttributes = SimpAttributes.fromMessage(message);
|
||||
try {
|
||||
SimpAttributesContextHolder.setAttributes(simpAttributes);
|
||||
@@ -462,7 +462,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||
}
|
||||
}
|
||||
|
||||
private Message<?> createDisconnectMessage(WebSocketSession session) {
|
||||
private Message<byte[]> createDisconnectMessage(WebSocketSession session) {
|
||||
StompHeaderAccessor headerAccessor = StompHeaderAccessor.create(StompCommand.DISCONNECT);
|
||||
if (getHeaderInitializer() != null) {
|
||||
getHeaderInitializer().initHeaders(headerAccessor);
|
||||
|
||||
Reference in New Issue
Block a user