@Override public ResourceAddress get(IoSession session) { SocketAddress remoteAddress = session.getRemoteAddress(); if (remoteAddress instanceof ResourceAddress) { return (ResourceAddress) remoteAddress; } return super.get(session); }
@Override public void setLoginContext(IoSession session, ResultAwareLoginContext loginContext) { WsnSession wsnSession = SESSION_KEY.get(session); assert wsnSession != null; wsnSession.setLoginContext(loginContext); }
@Override public void closeWebSocketConnection(IoSession session) { WsnSession wsnSession = SESSION_KEY.get(session); assert wsnSession != null; wsnSession.close(false); }
@Override public void closeWebSocketConnection(IoSession session) { WsnSession wsnSession = SESSION_KEY.get(session); assert wsnSession != null; wsnSession.close(false); }
@Override public ResourceAddress get(IoSession session) { SocketAddress localAddress = session.getLocalAddress(); if (localAddress instanceof ResourceAddress) { return (ResourceAddress) localAddress; } return super.get(session); }
protected Queue<InboundEvent> suspendInboundEvents(NextFilter nextFilter, IoSession session) throws Exception { Queue<InboundEvent> inboundEvents = inboundEventsKey.get(session); if (inboundEvents == null) { Queue<InboundEvent> newInboundEvents = new ConcurrentLinkedQueue<>(); inboundEvents = inboundEventsKey.setIfAbsent(session, newInboundEvents); if (inboundEvents == null) { inboundEvents = newInboundEvents; } } return inboundEvents; }
public static boolean writeExtraEmptyPacketRequired(IoSession session) { if ("x-kaazing-handshake".equals(BridgeSession.LOCAL_ADDRESS.get(session).getOption(NEXT_PROTOCOL))) { WsnSession wsnSession = (WsnSession) session; String query = wsnSession.getParentHttpRequestURI().getQuery(); return (query != null) && (query.contains(".kl=Y")||query.contains(".kv=10.05")); } return false; } }
private static void activateSessionIdleTimeout(IoSession session) { Integer keepaliveTimeout = SESSION_IDLE_TIMEOUT_KEY.get(session); if (keepaliveTimeout != null) { if (logger.isTraceEnabled()) { logger.trace(String.format("Setting idle timeout %d on HTTP parent session %s ", keepaliveTimeout, session)); } session.getConfig().setBothIdleTime(keepaliveTimeout); } }
@Override protected void doSessionClosed(IoSession session) throws Exception { WsrSession wsrSession = WSR_SESSION_KEY.get(session); if (wsrSession != null && !wsrSession.isClosing()) { // TODO: require RTMP controlled close handshake wsrSession.reset(new Exception("Early termination of IO session").fillInStackTrace()); } }
@Override public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception { Queue<InboundEvent> inboundEvents = inboundEventsKey.get(session); if (inboundEvents != null) { inboundEvents.add(new SessionCreatedEvent()); } else { super.sessionCreated(nextFilter, session); } }
@Override public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception { Queue<InboundEvent> inboundEvents = inboundEventsKey.get(session); if (inboundEvents != null) { inboundEvents.add(new SessionOpenedEvent()); } else { super.sessionOpened(nextFilter, session); } }
@Override public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception { Queue<InboundEvent> inboundEvents = inboundEventsKey.get(session); if (inboundEvents != null) { inboundEvents.add(new MessageSentEvent(writeRequest)); } else { super.messageSent(nextFilter, session, writeRequest); } }
@Override public void removeSession(IoSessionEx wsebSession) { if (ALREADY_TRACKED.get(wsebSession, false)) { // may not be set if wseb connection failed idleTracker.removeSession(((WsebSession)wsebSession).getTransportSession()); } }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void finishSessionInitialization0(IoSession session, IoFuture future) { ResourceAddress address = LOCAL_ADDRESS.get(session); IoSessionInitializer initializer = getInitializer(address); if (initializer != null) { initializer.initializeSession(session, future); } }
@Override protected void doSessionIdle(IoSession session, IdleStatus status) throws Exception { WsrSession wsrSession = WSR_SESSION_KEY.get(session); IoFilterChain filterChain = wsrSession.getFilterChain(); filterChain.fireSessionIdle(status); }
public IoSessionEx setParent(IoSessionEx newParent){ this.setLocalAddress(LOCAL_ADDRESS.get(newParent)); // newParent.getRemoteAddress(); httpSession.setLocalAddress((ResourceAddress)redirectRemoteAddress); upgradeFuture.setSession(newParent); if (!SslUtils.isSecure(newParent) && secure) { throw new InvalidParameterException("Can not switch from a secure session to a non-secure session"); } return super.setParent(newParent); }
private boolean deferOriginSecurityToHttpxe(IoSessionEx session, HttpRequestMessage httpRequest) { ResourceAddress resourceAddress = BridgeSession.LOCAL_ADDRESS.get(session); String nextProtocol = resourceAddress.getOption(NEXT_PROTOCOL); return "http/1.1".equals(nextProtocol) && isLegacyClient(httpRequest) && (isEmulatedWebSocketRequest(httpRequest) || isRevalidateWebSocketRequest(httpRequest)); }
public static void setDateHeader(IoSession session, HttpResponseMessage response) { DefaultHttpSession httpSession = HttpAcceptor.SESSION_KEY.get(session); if(httpSession != null) { ResourceAddress address = httpSession.getLocalAddress(); boolean dateHeaderEnabled = address.getOption(HttpResourceAddress.DATE_HEADER_ENABLED); if(dateHeaderEnabled && !response.hasHeader("Date")) { response.setHeader(HttpHeaders.HEADER_DATE, formatDateHeader(System.currentTimeMillis())); } } }
private ResourceAddress createWriteAddress(URI writeUri, HttpSession transport, WsebSession wsebSession) { ResourceAddress httpxeAddress = REMOTE_ADDRESS.get(transport); ResourceAddress writeAddress = httpxeAddress.resolve(writeUri.getPath()); String writeSessionIdentity = format("%s#%su", getTransportMetadata().getName(), wsebSession.getId()); IdentityResolver resolver = new FixedIdentityResolver(writeSessionIdentity); ResourceOptions options = ResourceOptions.FACTORY.newResourceOptions(writeAddress); options.setOption(ResourceAddress.IDENTITY_RESOLVER, resolver); return resourceAddressFactory.newResourceAddress(URIUtils.uriToString(writeAddress.getResource()), options); }
private void addSession0(IoSessionEx wsebSession) { if (ALREADY_TRACKED.get(wsebSession, false)) { // Expected for downstream reconnects return; } IoSessionEx transportSession = ((WsebSession)wsebSession).getTransportSession(); ALREADY_TRACKED.set(wsebSession, true); idleTracker.addSession(transportSession); WsCheckAliveFilter.addIfFeatureEnabled(transportSession.getFilterChain(), CHECK_ALIVE_FILTER, ((WsebSession) wsebSession).getLocalAddress().getOption(INACTIVITY_TIMEOUT), wsebSession, logger); }