All Downloads are FREE. Search and download functionalities are using the official Maven repository.

reactor.net.netty.NettyNetChannelOutboundHandler Maven / Gradle / Ivy

The newest version!
package reactor.net.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import reactor.tuple.Tuple2;

/**
 * @author Jon Brisbin
 */
public class NettyNetChannelOutboundHandler extends ChannelOutboundHandlerAdapter {
	@SuppressWarnings("unchecked")
	@Override
	public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
		if (Tuple2.class.isInstance(msg)) {
			Tuple2 tup = (Tuple2) msg;
			if (null != tup.getT1()) {
				super.write(ctx, tup.getT1(), promise);
			}
			if (tup.getT2()) {
				ctx.flush();
			}
		} else {
			super.write(ctx, msg, promise);
			ctx.flush();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy