當前位置: 首頁>>代碼示例>>Java>>正文


Java WebSocketSession.getUri方法代碼示例

本文整理匯總了Java中org.springframework.web.socket.WebSocketSession.getUri方法的典型用法代碼示例。如果您正苦於以下問題:Java WebSocketSession.getUri方法的具體用法?Java WebSocketSession.getUri怎麽用?Java WebSocketSession.getUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.socket.WebSocketSession的用法示例。


在下文中一共展示了WebSocketSession.getUri方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connectToProxiedTarget

import org.springframework.web.socket.WebSocketSession; //導入方法依賴的package包/類
private void connectToProxiedTarget(WebSocketSession session) {
	URI sessionUri = session.getUri();
	ZuulWebSocketProperties.WsBrokerage wsBrokerage = getWebSocketBrokarage(
			sessionUri);

	Assert.notNull(wsBrokerage, "wsBrokerage");

	String path = getWebSocketServerPath(wsBrokerage, sessionUri);
	Assert.notNull(path, "Web socket uri path");

	String routeHost = zuulPropertiesResolver.getRouteHost(wsBrokerage);
	Assert.notNull(routeHost, "routeHost");

       String uri = ServletUriComponentsBuilder
               .fromHttpUrl(routeHost)
               .path(path)
               .replaceQuery(sessionUri.getQuery())
               .toUriString();

	ProxyWebSocketConnectionManager connectionManager = new ProxyWebSocketConnectionManager(
			messagingTemplate, stompClient, session, headersCallback, uri);
	connectionManager.errorHandler(this.errorHandler);
	managers.put(session, connectionManager);
	connectionManager.start();
}
 
開發者ID:mthizo247,項目名稱:spring-cloud-netflix-zuul-websocket,代碼行數:26,代碼來源:ProxyWebSocketHandler.java

示例2: toRef

import org.springframework.web.socket.WebSocketSession; //導入方法依賴的package包/類
private PluginWebsocketSessionRef toRef(WebSocketSession session) throws IOException {
    URI sessionUri = session.getUri();
    String path = sessionUri.getPath();
    path = path.substring(WebSocketConfiguration.WS_PLUGIN_PREFIX.length());
    if (path.length() == 0) {
        throw new IllegalArgumentException("URL should contain plugin token!");
    }
    String[] pathElements = path.split("/");
    String pluginToken = pathElements[0];
    // TODO: cache
    PluginMetaData pluginMd = pluginService.findPluginByApiToken(pluginToken);
    if (pluginMd == null) {
        throw new InvalidParameterException("Can't find plugin with specified token!");
    } else {
        SecurityUser currentUser = (SecurityUser) session.getAttributes().get(WebSocketConfiguration.WS_SECURITY_USER_ATTRIBUTE);
        TenantId tenantId = currentUser.getTenantId();
        CustomerId customerId = currentUser.getCustomerId();
        if (PluginApiController.validatePluginAccess(pluginMd, tenantId, customerId)) {
            PluginApiCallSecurityContext securityCtx = new PluginApiCallSecurityContext(pluginMd.getTenantId(), pluginMd.getId(), tenantId,
                    currentUser.getCustomerId());
            return new BasicPluginWebsocketSessionRef(UUID.randomUUID().toString(), securityCtx, session.getUri(), session.getAttributes(),
                    session.getLocalAddress(), session.getRemoteAddress());
        } else {
            throw new SecurityException("Current user is not allowed to use this plugin!");
        }
    }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:28,代碼來源:PluginWebSocketHandler.java


注:本文中的org.springframework.web.socket.WebSocketSession.getUri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。