code: private void initCodec(IoSession session) throws Exception {
          // Creates the decoder and stores it into the newly created session
          ProtocolDecoder decoder = factory.getDecoder(session);
          session.setAttribute(DECODER, decoder);
  
          // Creates the encoder and stores it into the newly created session
          ProtocolEncoder encoder = factory.getEncoder(session);
          session.setAttribute(ENCODER, encoder);
      }
docs: Initialize the encoder and the decoder, storing them in the
  session attributes.