Class MessageToMessageEncoder<I>

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected MessageToMessageEncoder()
      Create a new instance which will try to detect the types to match out of the type parameter of the class.
      protected MessageToMessageEncoder​(Class<? extends I> outboundMessageType)
      Create a new instance
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean acceptOutboundMessage​(Object msg)
      Returns true if the given message should be handled.
      protected abstract void encode​(io.netty.channel.ChannelHandlerContext ctx, I msg, List<Object> out)
      Encode from one message to an other.
      void write​(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)  
      • Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        exceptionCaught, handlerAdded, handlerRemoved
    • Constructor Detail

      • MessageToMessageEncoder

        protected MessageToMessageEncoder()
        Create a new instance which will try to detect the types to match out of the type parameter of the class.
      • MessageToMessageEncoder

        protected MessageToMessageEncoder​(Class<? extends I> outboundMessageType)
        Create a new instance
        Parameters:
        outboundMessageType - The type of messages to match and so encode
    • Method Detail

      • acceptOutboundMessage

        public boolean acceptOutboundMessage​(Object msg)
                                      throws Exception
        Returns true if the given message should be handled. If false it will be passed to the next ChannelOutboundHandler in the ChannelPipeline.
        Throws:
        Exception
      • write

        public void write​(io.netty.channel.ChannelHandlerContext ctx,
                          Object msg,
                          io.netty.channel.ChannelPromise promise)
                   throws Exception
        Specified by:
        write in interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        write in class io.netty.channel.ChannelOutboundHandlerAdapter
        Throws:
        Exception
      • encode

        protected abstract void encode​(io.netty.channel.ChannelHandlerContext ctx,
                                       I msg,
                                       List<Object> out)
                                throws Exception
        Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.
        Parameters:
        ctx - the ChannelHandlerContext which this MessageToMessageEncoder belongs to
        msg - the message to encode to an other one
        out - the List into which the encoded msg should be added needs to do some kind of aggregation
        Throws:
        Exception - is thrown if an error occurs