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

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

Introduction

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

Prototype

@Nullable
SimpSession getSession(String sessionId);

Source Link

Document

Look up the session for the given id.

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   w  w w . j  ava2 s. co m*/
            Set<SimpSession> sessions = user.getSessions();
            sessionIds = new HashSet<>(sessions.size());
            for (SimpSession session : sessions) {
                sessionIds.add(session.getId());
            }
        }
    } else {
        sessionIds = Collections.emptySet();
    }
    return sessionIds;
}