当前位置: 首页>>代码示例>>Java>>正文


Java ServerEndpointConfig.Configurator方法代码示例

本文整理汇总了Java中javax.websocket.server.ServerEndpointConfig.Configurator方法的典型用法代码示例。如果您正苦于以下问题:Java ServerEndpointConfig.Configurator方法的具体用法?Java ServerEndpointConfig.Configurator怎么用?Java ServerEndpointConfig.Configurator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.websocket.server.ServerEndpointConfig的用法示例。


在下文中一共展示了ServerEndpointConfig.Configurator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerRooms

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private Set<ServerEndpointConfig> registerRooms(Collection<Room> rooms) {

        Set<ServerEndpointConfig> endpoints = new HashSet<ServerEndpointConfig>();
        for (Room room : rooms) {

            RoomRegistrationHandler roomRegistration = new RoomRegistrationHandler(room, systemId, registrationSecret);
            try{
                roomRegistration.performRegistration();
            }catch(Exception e){
                Log.log(Level.SEVERE, this, "Room Registration FAILED", e);
                //we keep running, maybe we were registered ok before...
            }

            //now regardless of our registration, open our websocket.
            SessionRoomResponseProcessor srrp = new SessionRoomResponseProcessor();
            ServerEndpointConfig.Configurator config = new RoomWSConfig(room, srrp, roomRegistration.getToken());

            endpoints.add(ServerEndpointConfig.Builder.create(RoomWS.class, "/ws/" + room.getRoomId())
                    .configurator(config).build());
        }

        return endpoints;
    }
 
开发者ID:gameontext,项目名称:gameon-room,代码行数:24,代码来源:LifecycleManager.java

示例2: initWebsocketRpcRuntime

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private void initWebsocketRpcRuntime(final ServletContext ctx, final RpcSpringContext rpcCtx) {
    LOGGER.info("Starting Websocket RPC runtime");
    ServerEndpointConfig.Configurator cfg = new WebsocketEndpointConfigurator(ctx, rpcCtx);
    ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(WebsocketEndpoint.class, RpcConfig.getInstance().getPath() + "/wskt").configurator(cfg).build();
    try {
        rpcCtx.getWebsocketContainer().addEndpoint(sec);
    } catch (DeploymentException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:brutusin,项目名称:Brutusin-RPC,代码行数:11,代码来源:RpcWebInitializer.java

示例3: getConfigurator

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
@Override
public Configurator getConfigurator() {
    for (ServerEndpointConfig.Configurator impl : ServiceLoader.load(javax.websocket.server.ServerEndpointConfig.Configurator.class)) {
        return impl;
    }
    throw new IllegalStateException("Cannot load platform configurator");
}
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:8,代码来源:HelloServerConfig.java

示例4: configuratorFor

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private ServerEndpointConfig.Configurator configuratorFor(final String prefix, final boolean isRaw) {
	return new ServerEndpointConfig.Configurator() {

		@Override
		public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
			try {
				return endpointClass.getConstructor(SockJsServer.class, String.class, String.class)
						.newInstance(sockJsServer, context.getContextPath(), prefix);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}

		@Override
		public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request,
				HandshakeResponse response) {
			if (isRaw) {
				// We have no reliable key (like session id) to save
				// headers with for raw websocket requests
				return;
			}
			String path = request.getRequestURI().getPath();
			Matcher matcher = SESSION_PATTERN.matcher(path);
			if (matcher.matches()) {
				String sessionId = matcher.group(1);
				saveHeaders(sessionId, request.getHeaders());
			}
		}
	};
}
 
开发者ID:bessemHmidi,项目名称:AngularBeans,代码行数:31,代码来源:AngularBeansServletContextListener.java

示例5: configuratorFor

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private ServerEndpointConfig.Configurator configuratorFor(final String prefix, final boolean isRaw) {
	return new ServerEndpointConfig.Configurator() {

		@Override
		public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
			try {
				return endpointClass.getConstructor(SockJsServer.class, String.class, String.class)
						.newInstance(sockJsServer, getServletContext().getContextPath(), prefix);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}

		@Override
		public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request,
				HandshakeResponse response) {

			if (isRaw) {
				// We have no reliable key (like session id) to save
				// headers with for raw websocket requests
				return;
			}

			String path = request.getRequestURI().getPath();
			Matcher matcher = SESSION_PATTERN.matcher(path);
			if (matcher.matches()) {
				String sessionId = matcher.group(1);
				saveHeaders(sessionId, request.getHeaders());
			}
		}
	};
}
 
开发者ID:bessemHmidi,项目名称:AngularBeans,代码行数:33,代码来源:SockJsServlet.java

示例6: test_store_request_headers_in_the_user_properties_map_during_handshake

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
@Test
public void test_store_request_headers_in_the_user_properties_map_during_handshake() {
    ServerEndpointConfig.Configurator configurator = new DaggerEndpointConfigurator(null);
    HandshakeRequest handshakeRequest = createHandshakeRequest();
    ServerEndpointConfig endpointConfig = createServerEndpointConfig();

    configurator.modifyHandshake(endpointConfig, handshakeRequest, null);

    assertSame(handshakeRequest.getHeaders(), endpointConfig.getUserProperties().get(DaggerEndpointConfigurator.REQUEST_HEADERS_KEY));
}
 
开发者ID:ccidral,项目名称:dagger,代码行数:11,代码来源:DaggerEndpointConfiguratorTest.java

示例7: DelegatingConfigurator

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
public DelegatingConfigurator(final ServerEndpointConfig.Configurator delegate) {
    this.delegate = delegate;
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:4,代码来源:DelegatingConfigurator.java

示例8: WebsocketBundle

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
public WebsocketBundle(ServerEndpointConfig.Configurator defaultConfigurator, Class<?>... endpoints) {
    this(defaultConfigurator, Arrays.asList(endpoints), new ArrayList<>());
}
 
开发者ID:LivePersonInc,项目名称:dropwizard-websockets,代码行数:4,代码来源:WebsocketBundle.java

示例9: DefaultServerEndpointConfig

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/**
 * <p>Constructor for DefaultServerEndpointConfig.</p>
 *
 * @param manager a manager
 * @param endpointClass  a {@link java.lang.Class} endpoint class.
 * @param webSocketConf  a {@link ameba.websocket.WebSocket} object.
 */
public DefaultServerEndpointConfig(final InjectionManager manager,
                                   Class endpointClass,
                                   final WebSocket webSocketConf) {
    path = webSocketConf.path();
    subprotocols = Arrays.asList(webSocketConf.subprotocols());
    encoders = Lists.newArrayList(webSocketConf.encoders());
    decoders = Lists.newArrayList(webSocketConf.decoders());
    for (Class<? extends Extension> extensionClass : webSocketConf.extensions()) {
        extensions.add(Injections.getOrCreate(manager, extensionClass));
    }
    final WebSocketEndpointProvider provider = manager.getInstance(WebSocketEndpointProvider.class);

    final EndpointMeta endpointMeta = provider.parseMeta(endpointClass, webSocketConf);

    final ServerEndpointConfig.Configurator cfgr =
            Injections.getOrCreate(manager, webSocketConf.configurator());
    serverEndpointConfigurator = new ServerEndpointConfig.Configurator() {

        @Override
        public String getNegotiatedSubprotocol(List<String> supported, List<String> requested) {
            return cfgr.getNegotiatedSubprotocol(supported, requested);
        }

        @Override
        public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) {
            return cfgr.getNegotiatedExtensions(installed, requested);
        }

        @Override
        public boolean checkOrigin(String originHeaderValue) {
            return cfgr.checkOrigin(originHeaderValue);
        }

        @Override
        public void modifyHandshake(ServerEndpointConfig sec,
                                    HandshakeRequest request, HandshakeResponse response) {
            cfgr.modifyHandshake(sec, request, response);
        }

        @Override
        public <T> T getEndpointInstance(Class<T> eClass) throws InstantiationException {
            if (EndpointDelegate.class.equals(eClass)) {
                return eClass.cast(new EndpointDelegate(endpointMeta));
            }
            return cfgr.getEndpointInstance(eClass);
        }
    };
}
 
开发者ID:icode,项目名称:ameba,代码行数:56,代码来源:DefaultServerEndpointConfig.java

示例10: getConfigurator

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public ServerEndpointConfig.Configurator getConfigurator() {
    return serverEndpointConfigurator;
}
 
开发者ID:icode,项目名称:ameba,代码行数:6,代码来源:DefaultServerEndpointConfig.java


注:本文中的javax.websocket.server.ServerEndpointConfig.Configurator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。