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();
}
}