@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg != null && DatagramPacket.class.isAssignableFrom(msg.getClass())) { super.channelRead(ctx, ((DatagramPacket) msg).content()); } else { super.channelRead(ctx, msg); } } },
protected ChannelFuture doOnWrite(Object data, ChannelHandlerContext ctx) { if (data.getClass().equals(Buffer.class)) { return ctx.channel().write(convertBufferToByteBuff(ctx, (Buffer) data)); } else if (Unpooled.EMPTY_BUFFER != data) { return ctx.channel().write(data); } return null; }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { doRead(ctx, msg); }
if (remainder == null) { try { passToConnection(data); } finally { if (data.isReadable()) { if (!bufferHasSufficientCapacity(remainder, data)) { ByteBuf combined = createCombinedBuffer(remainder, data, ctx); remainder.release(); remainder = combined; passToConnection(remainder); } finally { if (remainder.isReadable()) {
protected void bindChannel(ReactorChannelHandler<IN, OUT, ChannelStream<IN, OUT>> handler, SocketChannel nativeChannel) { NettyChannelStream<IN, OUT> netChannel = new NettyChannelStream<IN, OUT>( getDefaultEnvironment(), getDefaultCodec(), getDefaultPrefetchSize(), getDefaultDispatcher(), nativeChannel ); ChannelPipeline pipeline = nativeChannel.pipeline(); if (log.isDebugEnabled()) { pipeline.addLast(new LoggingHandler(NettyTcpClient.class)); } pipeline.addLast( new NettyChannelHandlerBridge<IN, OUT>(handler, netChannel) ); }
@Override @SuppressWarnings("unchecked") public void doDecoded(IN in) { NettyChannelHandlerBridge ch = ioChannel.pipeline().get(NettyChannelHandlerBridge.class); PushSubscription<IN> subscription = ch == null ? null : ch.subscription(); if (subscription != null) { try { subscription.onNext(in); } catch (CancelException ce){ } } }
protected void bindChannel(ReactorChannelHandler<IN, OUT, ChannelStream<IN, OUT>> handler, SocketChannel nativeChannel) { NettyChannelStream<IN ,OUT> netChannel = new NettyChannelStream<IN, OUT>( getDefaultEnvironment(), getDefaultCodec(), getDefaultPrefetchSize(), getDefaultDispatcher(), nativeChannel ); ChannelPipeline pipeline = nativeChannel.pipeline(); if(log.isDebugEnabled()){ pipeline.addLast(new LoggingHandler(NettyTcpServer.class)); } pipeline.addLast( new NettyChannelHandlerBridge<IN, OUT>(handler, netChannel) ); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { Class<?> messageClass = msg.getClass(); if (HttpResponse.class.isAssignableFrom(messageClass)) { HttpResponse response = (HttpResponse) msg; if (request != null) { request.setNettyResponse(response); } checkResponseCode(ctx, response); if(FullHttpResponse.class.isAssignableFrom(messageClass)){ postRead(ctx, msg); } ctx.fireChannelRead(msg); } else if (HttpContent.class.isAssignableFrom(messageClass)) { super.channelRead(ctx, ((ByteBufHolder) msg).content()); postRead(ctx, msg); } else if(!discardBody){ super.channelRead(ctx, msg); } }
super.channelRead(ctx, ((ByteBufHolder) msg).content());