Example usage for org.springframework.messaging.simp.user SimpUser getSessions

List of usage examples for org.springframework.messaging.simp.user SimpUser getSessions

Introduction

In this page you can find the example usage for org.springframework.messaging.simp.user SimpUser getSessions.

Prototype

Set<SimpSession> getSessions();

Source Link

Document

Return the sessions for the user.

Usage

From source file:org.springframework.messaging.simp.user.DefaultUserDestinationResolver.java

private Set<String> getSessionIdsByUser(String userName, @Nullable String sessionId) {
    Set<String> sessionIds;
    SimpUser user = this.userRegistry.getUser(userName);
    if (user != null) {
        if (sessionId != null && user.getSession(sessionId) != null) {
            sessionIds = Collections.singleton(sessionId);
        } else {/*from  ww w  . j  a  v a  2s  .  c  om*/
            Set<SimpSession> sessions = user.getSessions();
            sessionIds = new HashSet<>(sessions.size());
            for (SimpSession session : sessions) {
                sessionIds.add(session.getId());
            }
        }
    } else {
        sessionIds = Collections.emptySet();
    }
    return sessionIds;
}