Search in sources :

Example 1 with SubProtocolCapable

use of org.springframework.web.socket.SubProtocolCapable in project spring-framework by spring-projects.

the class AbstractHandshakeHandler method determineHandlerSupportedProtocols.

/**
	 * Determine the sub-protocols supported by the given WebSocketHandler by
	 * checking whether it is an instance of {@link SubProtocolCapable}.
	 * @param handler the handler to check
	 * @return a list of supported protocols, or an empty list if none available
	 */
protected final List<String> determineHandlerSupportedProtocols(WebSocketHandler handler) {
    WebSocketHandler handlerToCheck = WebSocketHandlerDecorator.unwrap(handler);
    List<String> subProtocols = null;
    if (handlerToCheck instanceof SubProtocolCapable) {
        subProtocols = ((SubProtocolCapable) handlerToCheck).getSubProtocols();
    }
    return (subProtocols != null ? subProtocols : Collections.emptyList());
}
Also used : SubProtocolCapable(org.springframework.web.socket.SubProtocolCapable) WebSocketHandler(org.springframework.web.socket.WebSocketHandler)

Aggregations

SubProtocolCapable (org.springframework.web.socket.SubProtocolCapable)1 WebSocketHandler (org.springframework.web.socket.WebSocketHandler)1