/** * Perform the sub-protocol negotiation based on requested and supported sub-protocols. * For the list of supported sub-protocols, this method first checks if the target * WebSocketHandler is a {@link SubProtocolCapable} and then also checks if any * sub-protocols have been explicitly configured with * {@link #setSupportedProtocols(String...)}. * @param requestedProtocols the requested sub-protocols * @param webSocketHandler the WebSocketHandler that will be used * @return the selected protocols or {@code null} * @see #determineHandlerSupportedProtocols(WebSocketHandler) */ @Nullable protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) { List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler); for (String protocol : requestedProtocols) { if (handlerProtocols.contains(protocol.toLowerCase())) { return protocol; } if (this.supportedProtocols.contains(protocol.toLowerCase())) { return protocol; } } return null; }
/** * Perform the sub-protocol negotiation based on requested and supported sub-protocols. * For the list of supported sub-protocols, this method first checks if the target * WebSocketHandler is a {@link SubProtocolCapable} and then also checks if any * sub-protocols have been explicitly configured with * {@link #setSupportedProtocols(String...)}. * @param requestedProtocols the requested sub-protocols * @param webSocketHandler the WebSocketHandler that will be used * @return the selected protocols or {@code null} * @see #determineHandlerSupportedProtocols(WebSocketHandler) */ @Nullable protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) { List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler); for (String protocol : requestedProtocols) { if (handlerProtocols.contains(protocol.toLowerCase())) { return protocol; } if (this.supportedProtocols.contains(protocol.toLowerCase())) { return protocol; } } return null; }
/** * Perform the sub-protocol negotiation based on requested and supported sub-protocols. * For the list of supported sub-protocols, this method first checks if the target * WebSocketHandler is a {@link SubProtocolCapable} and then also checks if any * sub-protocols have been explicitly configured with * {@link #setSupportedProtocols(String...)}. * @param requestedProtocols the requested sub-protocols * @param webSocketHandler the WebSocketHandler that will be used * @return the selected protocols or {@code null} * @see #determineHandlerSupportedProtocols(WebSocketHandler) */ @Nullable protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) { List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler); for (String protocol : requestedProtocols) { if (handlerProtocols.contains(protocol.toLowerCase())) { return protocol; } if (this.supportedProtocols.contains(protocol.toLowerCase())) { return protocol; } } return null; }