Example usage for org.springframework.web.socket.messaging SubProtocolHandler resolveSessionId

List of usage examples for org.springframework.web.socket.messaging SubProtocolHandler resolveSessionId

Introduction

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

Prototype

@Nullable
String resolveSessionId(Message<?> message);

Source Link

Document

Resolve the session id from the given message or return null .

Usage

From source file:org.springframework.integration.websocket.support.SubProtocolHandlerRegistry.java

/**
 * Resolves the {@code sessionId} for the given {@code message} using
 * the {@link SubProtocolHandler#resolveSessionId} algorithm.
 * @param message The message to resolve the {@code sessionId} from.
 * @return The sessionId or {@code null}, if no one {@link SubProtocolHandler}
 * can't resolve it against provided {@code message}.
 *///from  w w w  . j  av  a 2s  .com
public String resolveSessionId(Message<?> message) {
    for (SubProtocolHandler handler : this.protocolHandlers.values()) {
        String sessionId = handler.resolveSessionId(message);
        if (sessionId != null) {
            return sessionId;
        }
    }
    if (this.defaultProtocolHandler != null) {
        String sessionId = this.defaultProtocolHandler.resolveSessionId(message);
        if (sessionId != null) {
            return sessionId;
        }
    }
    return null;
}

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

@Nullable
private String resolveSessionId(Message<?> message) {
    for (SubProtocolHandler handler : this.protocolHandlerLookup.values()) {
        String sessionId = handler.resolveSessionId(message);
        if (sessionId != null) {
            return sessionId;
        }/*from  ww w  .j  a  v a  2  s  .  co  m*/
    }
    if (this.defaultProtocolHandler != null) {
        String sessionId = this.defaultProtocolHandler.resolveSessionId(message);
        if (sessionId != null) {
            return sessionId;
        }
    }
    return null;
}