当前位置: 首页>>代码示例>>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;未经允许,请勿转载。