List of usage examples for javax.websocket WebSocketContainer setDefaultMaxSessionIdleTimeout
void setDefaultMaxSessionIdleTimeout(long timeout);
From source file:com.codeveo.lago.bot.stomp.client.AbstractHttpLagoBot.java
protected AbstractHttpLagoBot() { objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); /* jaxb only */ JaxbAnnotationModule module = new JaxbAnnotationModule(); objectMapper.registerModule(module); taskExecutor = new ThreadPoolTaskExecutor(); taskExecutor.setMaxPoolSize(THREAD_POOL_SIZE); taskExecutor.initialize();//from w w w.j ava2 s. c o m WebSocketContainer webSocketContainer = ContainerProvider.getWebSocketContainer(); webSocketContainer.setDefaultMaxSessionIdleTimeout(CLIENT_MAX_IDLE_TIMEOUT); webSocketClient = new StandardWebSocketClient(webSocketContainer); webSocketClient.setTaskExecutor(taskExecutor); }
From source file:co.paralleluniverse.comsat.webactors.AbstractWebActorTest.java
@Test public void testWebSocketMsg() throws IOException, InterruptedException, ExecutionException, DeploymentException { BasicCookieStore cookieStore = new BasicCookieStore(); final HttpGet httpGet = new HttpGet("http://localhost:8080"); HttpClients.custom().setDefaultRequestConfig(requestConfig).setDefaultCookieStore(cookieStore).build() .execute(httpGet, new BasicResponseHandler()); final SettableFuture<String> res = new SettableFuture<>(); final WebSocketContainer wsContainer = ContainerProvider.getWebSocketContainer(); wsContainer.setAsyncSendTimeout(timeout); wsContainer.setDefaultMaxSessionIdleTimeout(timeout); try (final Session ignored = wsContainer.connectToServer(sendAndGetTextEndPoint("test it", res), getClientEndPointConfig(cookieStore), URI.create("ws://localhost:8080/ws"))) { final String s = res.get(); assertEquals("test it", s); }/* ww w . ja v a2 s . c o m*/ }
From source file:io.hosuaby.restful.simulators.TeapotSimulator.java
/** * Creates and starts teapot simulator.//from www . j av a 2 s .c o m * * @param teapot teapot domain object * @param port port number of the server * * @throws URISyntaxException * @throws DeploymentException * @throws IOException */ public TeapotSimulator(Teapot teapot, int port) throws URISyntaxException, DeploymentException, IOException { /* Get websocket container */ final WebSocketContainer container = ContainerProvider.getWebSocketContainer(); /* Configuration of teapot client endpoint */ final ClientEndpointConfig teapotConfig = ClientEndpointConfig.Builder.create().build(); /* Disable websocket timeout */ container.setDefaultMaxSessionIdleTimeout(0); URI uri = new URI(String.format(REGISTER_URL, port, teapot.getId())); /* Create websocket client for the teapot */ container.connectToServer(new TeapotSimulatorEndpoint(this), teapotConfig, uri); /* Create the file system */ fs = new TeapotFs(); /* Create help.txt file */ fs.cat("help.txt", createHelpFileContent()); /* Create license file */ fs.cat("license", createLicenseFileContent()); /* Create config.json file */ fs.cat("config.json", createConfigFileContent(teapot)); }