public NettyChannelInitializer(final BridgeRuntime bridgeRuntime) { this.bridgeRuntime = bridgeRuntime; config = bridgeRuntime.config(); }
/** * Return the {@link org.atmosphere.cpr.AtmosphereFramework} instance * * @return the {@link AtmosphereFramework} instance */ public AtmosphereFramework framework() { return runtime.framework(); }
handleWebSocketHandshake(ctx, messageEvent); } else { if (config.webSocketOnly()) { logger.trace("Forbidenn {}", ctx); sendHttpResponse(ctx, r, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; handleHttp(ctx, messageEvent); handleWebSocketFrame(ctx, messageEvent); } else if (msg instanceof HttpChunkedInput) { handleHttp(ctx, messageEvent);
sendHttpResponse(ctx, request, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(getWebSocketLocation(request), config.subProtocols(), false, } else { final NettyWebSocket webSocket = new NettyWebSocket(ctx.channel(), framework.getAtmosphereConfig(), config.noInternalAlloc(), config.binaryWrite()); final AtmosphereRequest atmosphereRequest = createAtmosphereRequest(ctx, request, EMPTY); sendError(ctx, HttpResponseStatus.BAD_REQUEST, null); return;
private AtmosphereRequest createAtmosphereRequest(final ChannelHandlerContext ctx, final HttpRequest request, byte[] body) throws URISyntaxException, UnsupportedEncodingException, MalformedURLException { final String base = getBaseUri(request); final URI requestUri = new URI(base.substring(0, base.length() - 1) + request.getUri()); final String ct = HttpHeaders.getHeader(request, "Content-Type", "text/plain"); Map<String, String[]> qs = new HashMap<String, String[]>(); if (queryString != null) { parseQueryString(qs, queryString); parseQueryString(qs, new String(body)); .requestURL(url) .pathInfo(url.substring(l)) .headers(getHeaders(request)) .method(method) .contentType(ct) .servletPath(config.mappingPath()) .session(session) .cookies(getCookies(request)) .queryStrings(qs) .remoteInetSocketAddress((Callable<InetSocketAddress>) () -> (InetSocketAddress) ctx.channel().remoteAddress())
/** * Stop the Server */ public void stop() { if (started.getAndSet(false)) { runtime.destroy(); final ChannelGroupFuture future = ALL_CHANNELS.close(); future.awaitUninterruptibly(); ALL_CHANNELS.clear(); } }
private Nettosphere(Config config) { runtime = new BridgeRuntime(config); this.channelInitializer = new NettyChannelInitializer(runtime); this.localSocket = new InetSocketAddress(config.host(), config.port()); this.bootstrap = buildBootstrap(config); if (config.initParams().containsKey(FLASH_SUPPORT)) { this.bootstrapFlashPolicy = buildBootstrapFlashPolicy(config); localPolicySocket = new InetSocketAddress(843); } else { configureBootstrap(bootstrap, config); this.bootstrapFlashPolicy = null; localPolicySocket = null; } runtimeEngine = new RuntimeEngine(runtime); }
request = createAtmosphereRequest(ctx, hrequest, body); request.setAttribute(KEEP_ALIVE, ka);
handleWebSocketHandshake(ctx, messageEvent); } else { if (config.webSocketOnly()) { logger.trace("Forbidenn {}", ctx); sendHttpResponse(ctx, r, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; handleHttp(ctx, messageEvent); handleWebSocketFrame(ctx, messageEvent); } else if (msg instanceof HttpChunkedInput) { handleHttp(ctx, messageEvent);
sendHttpResponse(ctx, request, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(getWebSocketLocation(request), config.subProtocols(), false, } else { final NettyWebSocket webSocket = new NettyWebSocket(ctx.channel(), framework.getAtmosphereConfig(), config.noInternalAlloc(), config.binaryWrite()); final AtmosphereRequest atmosphereRequest = createAtmosphereRequest(ctx, request, EMPTY); sendError(ctx, HttpResponseStatus.BAD_REQUEST, null); return;
private AtmosphereRequest createAtmosphereRequest(final ChannelHandlerContext ctx, final HttpRequest request, byte[] body) throws URISyntaxException, UnsupportedEncodingException, MalformedURLException { final String base = getBaseUri(request); final URI requestUri = new URI(base.substring(0, base.length() - 1) + request.getUri()); final String ct = HttpHeaders.getHeader(request, "Content-Type", "text/plain"); Map<String, String[]> qs = new HashMap<String, String[]>(); if (queryString != null) { parseQueryString(qs, queryString); parseQueryString(qs, new String(body)); .requestURL(url) .pathInfo(url.substring(l)) .headers(getHeaders(request)) .method(method) .contentType(ct) .servletPath(config.mappingPath()) .session(session) .cookies(getCookies(request)) .queryStrings(qs) .remoteInetSocketAddress((Callable<InetSocketAddress>) () -> (InetSocketAddress) ctx.channel().remoteAddress())
/** * Stop the Server */ public void stop() { if (started.getAndSet(false)) { runtime.destroy(); final ChannelGroupFuture future = ALL_CHANNELS.close(); future.awaitUninterruptibly(); ALL_CHANNELS.clear(); } }
private Nettosphere(Config config) { runtime = new BridgeRuntime(config); this.channelInitializer = new NettyChannelInitializer(runtime); this.localSocket = new InetSocketAddress(config.host(), config.port()); this.bootstrap = buildBootstrap(config); if (config.initParams().containsKey(FLASH_SUPPORT)) { this.bootstrapFlashPolicy = buildBootstrapFlashPolicy(config); localPolicySocket = new InetSocketAddress(843); } else { configureBootstrap(bootstrap, config); this.bootstrapFlashPolicy = null; localPolicySocket = null; } runtimeEngine = new RuntimeEngine(runtime); }
request = createAtmosphereRequest(ctx, hrequest, body); request.setAttribute(KEEP_ALIVE, ka);
/** * Return the {@link org.atmosphere.cpr.AtmosphereFramework} instance * * @return the {@link AtmosphereFramework} instance */ public AtmosphereFramework framework() { return runtime.framework(); }
public NettyChannelInitializer(final BridgeRuntime bridgeRuntime) { this.bridgeRuntime = bridgeRuntime; config = bridgeRuntime.config(); }