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

org.rx.net.socks.ProxyChannelIdleHandler Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package org.rx.net.socks;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.IdleStateHandler;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.rx.net.Sockets;

@Slf4j
public class ProxyChannelIdleHandler extends IdleStateHandler {
    public ProxyChannelIdleHandler(int readerIdleTimeSeconds, int writerIdleTimeSeconds) {
        super(readerIdleTimeSeconds, writerIdleTimeSeconds, 0);
    }

    //userEventTriggered not fire
    @SneakyThrows
    @Override
    protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) {
        log.info("{} {} idle: {}", Sockets.protocolName(ctx.channel()), ctx.channel(), evt.state());
        Sockets.closeOnFlushed(ctx.channel());
        SocksContext sc = SocksContext.ctx(ctx.channel());
        if (sc.onClose != null) {
            sc.onClose.invoke();
        }
        super.channelIdle(ctx, evt);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy