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

io.github.duoduobabi.iproxy.handler.DirectClientHandler Maven / Gradle / Ivy

package io.github.duoduobabi.iproxy.handler;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.concurrent.Promise;

/**
 * @author cuiyang
 */
public final class DirectClientHandler extends ChannelInboundHandlerAdapter {

    private final Promise promise;

    public DirectClientHandler(Promise promise) {
        this.promise = promise;
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) {
        ctx.pipeline().remove(this);
        promise.setSuccess(ctx.channel());
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable throwable) {
        promise.setFailure(throwable);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy