下面列出了怎么用org.springframework.web.socket.SubProtocolCapable的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* 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());
}
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession sockJsSession) {
Assert.notNull(serviceConfig, "serviceConfig must not be null");
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
Assert.notNull(sockJsSession, "session must not be null");
this.sockJsServiceConfig = serviceConfig;
this.sockJsSession = sockJsSession;
webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler);
this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ?
new ArrayList<>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : Collections.emptyList());
}
/**
* 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());
}
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession sockJsSession) {
Assert.notNull(serviceConfig, "serviceConfig must not be null");
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
Assert.notNull(sockJsSession, "session must not be null");
this.sockJsServiceConfig = serviceConfig;
this.sockJsSession = sockJsSession;
webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler);
this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ?
new ArrayList<>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : Collections.emptyList());
}
/**
* 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.<String>emptyList());
}
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession sockJsSession) {
Assert.notNull(serviceConfig, "serviceConfig must not be null");
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
Assert.notNull(sockJsSession, "session must not be null");
this.sockJsServiceConfig = serviceConfig;
this.sockJsSession = sockJsSession;
webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler);
this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ?
new ArrayList<String>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : null);
}