@OnOpen public void open(Session session) { this.session = session; session.setMaxIdleTimeout(0); Object debugger = session.getUserProperties().get("chrome.rdp"); if (debugger instanceof ChromeRDPExchangeConsumer) { this.debugger = (ChromeRDPExchangeConsumer) debugger; this.debugger.setExchange(this); } }
if (webSocketWriteTimeout != -1) session.setMaxIdleTimeout(webSocketWriteTimeout); if (maxTextBufferSize != -1) session.setMaxTextMessageBufferSize(maxTextBufferSize);
@OnOpen public void onWebSocketConnect(Session session) { log.debug("onWebSocketConnect: {}", session); synchronized (monitor) { boolean firstSession = sessions.isEmpty(); session.setMaxIdleTimeout(30000); sessions.add(new SpawnWebSocketSession(session)); // wake up update thread now that we have an active websocket session if (firstSession) { monitor.notify(); } } }
@OnOpen public void onOpen(Session session) { String combinedEndpointId = getOrGenerateCombinedEndpointId(session); LOG.debug("Web socket session opened"); LOG.debug("Endpoint: {}", combinedEndpointId); session.setMaxIdleTimeout(0); registry.add(combinedEndpointId, session); reSender.resend(combinedEndpointId); sessionMessagesBuffer.put(session, new StringBuffer()); }
/** * Connect the WebSocket to the server pointing to /ws/{token} to receive events. * * @throws SaltException in case of an error during stream initialization */ private void initializeStream(URI uri, Token token, long sessionIdleTimeout, long idleTimeout) throws SaltException { try { URI adjustedURI = new URI(uri.getScheme() == "https" ? "wss" : "ws", uri.getSchemeSpecificPart(), uri.getFragment()) .resolve("ws/" + token.getToken()); websocketContainer.setDefaultMaxSessionIdleTimeout(sessionIdleTimeout); // Initiate the websocket handshake synchronized (websocketContainer) { session = websocketContainer.connectToServer(this, adjustedURI); session.setMaxIdleTimeout(idleTimeout); } } catch (URISyntaxException | DeploymentException | IOException e) { throw new SaltException(e); } }
@Override public void onOpen(Session session, EndpointConfig config) { try{ openCount.incrementAndGet(); if(timeout!=null){ session.setMaxIdleTimeout(timeout*1000); } WebSocket ws = new WebSocket(session); socket.set(ws); ws.setName(uri.toString()); if(handlerFunction!=null){ ws.setMessageHandler( arg -> { synchronized(handlerFunction) { handlerFunction.apply(arg); } }, messageFormat ); } if(openMessage.get()!=null){ ws.call(openMessage.get()); } } catch(Exception e){ log.log(Level.SEVERE,"Error opening web socket session "+uri,e); } } @Override
@OnOpen public void open(Session session, EndpointConfig conf, @PathParam("cid") String cid) { // HandshakeRequest req = (HandshakeRequest) conf.getUserProperties() // .get("handshakereq"); try { session.setMaxIdleTimeout(timeout); session.getBasicRemote().sendObject(new Message("Welcome")); } catch (IOException e) { logger.error(e.toString()); } catch (EncodeException e) { logger.error(e.toString()); } /* Register this connection in the queue */ users.put(cid, session); logger.info("Connection opened.login user id {},login time {}", cid, new Date()); }
@Override public void onOpen(Session session, EndpointConfig endpointConfig) { // set timeout long oldMaxIdleTimeout = session.getMaxIdleTimeout(); long newMaxIdleTimeout = 0; session.setMaxIdleTimeout(newMaxIdleTimeout); if (log.isDebugEnabled()) log.debug("Changed max idle timeout of session " + session.getId() + " from " + oldMaxIdleTimeout + " to " + newMaxIdleTimeout); // read properties ClientEndpointConfig clientEndpointConfig = (ClientEndpointConfig) endpointConfig; URI xdiWebSocketEndpointUri = (URI) clientEndpointConfig.getUserProperties().get("xdiWebSocketEndpointUri"); // init message handler WebSocketClientMessageHandler webSocketMessageHandler = new WebSocketClientMessageHandler(session); // init session log.info("WebSocket session " + session.getId() + " opened (" + xdiWebSocketEndpointUri + ")."); session.addMessageHandler(webSocketMessageHandler); session.getUserProperties().putAll(clientEndpointConfig.getUserProperties()); }
@Override public void onOpen(Session session, EndpointConfig endpointConfig) { // set timeout long oldMaxIdleTimeout = session.getMaxIdleTimeout(); long newMaxIdleTimeout = 0; session.setMaxIdleTimeout(newMaxIdleTimeout); if (log.isDebugEnabled()) log.debug("Changed max idle timeout of session " + session.getId() + " from " + oldMaxIdleTimeout + " to " + newMaxIdleTimeout); // read properties ServerEndpointConfig serverEndpointConfig = (ServerEndpointConfig) endpointConfig; WebSocketTransport webSocketTransport = (WebSocketTransport) serverEndpointConfig.getUserProperties().get("webSocketTransport"); // init message handler WebSocketServerMessageHandler webSocketMessageHandler = new WebSocketServerMessageHandler(session); // init session log.info("WebSocket session " + session.getId() + " opened (" + serverEndpointConfig.getPath() + ")."); session.addMessageHandler(webSocketMessageHandler); session.getUserProperties().putAll(serverEndpointConfig.getUserProperties()); // register session webSocketTransport.registerSession(session, null); }
/** * Add given web socket session to the {@link WebocketSessionManager}. If web socket session is not accepted (i.e. the * channel identifier is unknown), then immediately close with reason VIOLATED_POLICY (close code 1008). * @param session The opened web socket session. * @param config The endpoint configuration. */ @Override public void onOpen(Session session, EndpointConfig config) { if (WebsocketSessionManager.getInstance().add(session)) { // @Inject in Endpoint doesn't work in Tomcat+Weld/OWB. session.setMaxIdleTimeout(0); } else { try { session.close(REASON_UNKNOWN_CHANNEL); } catch (IOException e) { onError(session, e); } } }
/** * Add given web socket session to the {@link WebocketSessionManager}. If web socket session is not accepted (i.e. the * channel identifier is unknown), then immediately close with reason VIOLATED_POLICY (close code 1008). * @param session The opened web socket session. * @param config The endpoint configuration. */ @Override public void onOpen(Session session, EndpointConfig config) { if (WebsocketSessionManager.getInstance().add(session)) { // @Inject in Endpoint doesn't work in Tomcat+Weld/OWB. session.setMaxIdleTimeout(0); } else { try { session.close(REASON_UNKNOWN_CHANNEL); } catch (IOException e) { onError(session, e); } } }
/** * Add given web socket session to the {@link SocketSessionManager}. If web socket session is not accepted (i.e. the * channel identifier is unknown), then immediately close with reason VIOLATED_POLICY (close code 1008). * @param session The opened web socket session. * @param config The endpoint configuration. */ @Override public void onOpen(Session session, EndpointConfig config) { if (SocketSessionManager.getInstance().add(session)) { // @Inject in Endpoint doesn't work in Tomcat+Weld/OWB. session.setMaxIdleTimeout(0); } else { try { session.close(REASON_UNKNOWN_CHANNEL); } catch (IOException e) { onError(session, e); } } }
/** * Add given web socket session to the {@link WebocketSessionManager}. If web socket session is not accepted (i.e. the * channel identifier is unknown), then immediately close with reason VIOLATED_POLICY (close code 1008). * @param session The opened web socket session. * @param config The endpoint configuration. */ @Override public void onOpen(Session session, EndpointConfig config) { if (WebsocketSessionManager.getInstance().add(session)) { // @Inject in Endpoint doesn't work in Tomcat+Weld/OWB. session.setMaxIdleTimeout(0); } else { try { session.close(REASON_UNKNOWN_CHANNEL); } catch (IOException e) { onError(session, e); } } }
/** * Add given web socket session to the {@link SocketSessionManager}. If web socket session is not accepted (i.e. the * channel identifier is unknown), then immediately close with reason VIOLATED_POLICY (close code 1008). * @param session The opened web socket session. * @param config The endpoint configuration. */ @Override public void onOpen(Session session, EndpointConfig config) { if (SocketSessionManager.getInstance().add(session)) { // @Inject in Endpoint doesn't work in Tomcat+Weld/OWB. session.setMaxIdleTimeout(0); } else { try { session.close(REASON_UNKNOWN_CHANNEL); } catch (IOException e) { onError(session, e); } } }
WebsocketApplicationSessionHolder.addOrUpdateSession(channelToken, session)) session.setMaxIdleTimeout((Long) config.getUserProperties().getOrDefault( WebsocketConfigurator.MAX_IDLE_TIMEOUT, 300000L));
session.setMaxIdleTimeout(channel.getGravity().getGravityConfig().getChannelIdleTimeoutMillis()); channel.onWebSocketConnect(session);