ChannelInboundHandlerAdapter in netty



  • There's a class to follow. ChannelInboundHandlerAdapterwhere I redesign the right methods. For example, channelUnregistered:

    public abstract class HttpServerHandler extends ChannelInboundHandlerAdapter{
    
    @Override
    public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
        super. channelUnregistered(ctx);
        // something doing here
    }
    [...]
    

    }

    If you use this class, channelUnregistered works when the connection closes to the client.

    But if I inherit from him,

    public abstract class HttpsServerHandler extends HttpServerHandler {

    }

    Using this class channelUnregistered Never works. But if I redesign this method and just call the method. super Class, everything works:

    public abstract class HttpsServerHandler extends HttpServerHandler {

    @Override
    public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
        super. channelUnregistered(ctx);
    }
    

    }

    My brain refuses to work. In the base class, there's this method, if I don't redesign it daughter, the basic class method must be triggered. Or am I missing something?



  • Netty has a ServerBootstrap class that needs to be set up in the building. One of the necessary constructions is the function of a childHandler() to which a Channel-Handler object is transferred, which is obliged to monitor the canal ' s requests. Thus, for each new compound, a ChannelHandler object is being created, which you have previously linked with childHandler(). However, your classes have been declared abstract and, apparently, their copies are not created anywhere. If you tie HtpsServerHandler to your server, everything has to work.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2