Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7037541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:33:28+00:00 2026-05-28T01:33:28+00:00

If you created your pipe like this: pipeline.addLast(decoder, new StringDecoder()); pipeline.addLast(encoder, new StringEncoder()); Is

  • 0

If you created your pipe like this:

    pipeline.addLast("decoder", new StringDecoder());
    pipeline.addLast("encoder", new StringEncoder());

Is there any way to get the raw data from a pipeline that usually handles text?
I’d really like to do this:

    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
      // Save data received from the server.
      Object msg = e.getMessage();
      byte[] rawdata = new byte[((ChannelBuffer)msg).readableBytes()];
      ((ChannelBuffer)msg).getBytes(0, rawdata);
      tmpTarFile.write(rawdata);
    }

The channel is mostly text, but sometimes I need to read raw binary out of it.
In this case the msg that comes in is a String object because of the StringDecoder in the pipeline. I’d like to get the channelbuffer data beneath that string…

On the server side, the data was written with this:

        ChannelBuffer databuffer = ChannelBuffers.buffer(blobstream.size());
        databuffer.writeBytes(blobstream.toByteArray());
        e.getChannel().write(databuffer);

Looks like I have to turn off the stringencoder/decoder (which converts it into a ChannelBuffer w/ raw byte access) and convert bytes to/from Strings…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:33:29+00:00Added an answer on May 28, 2026 at 1:33 am

    If you want to get the raw ChannelBuffer you will need to remove the Decoder from the pipeline and then once you want to handle String’s again just add it back.

    You could also extend the StringDecoder and based on some logic decode it or not.
    Something like that:

    public class FlexibleStringDecoder extends StringDecoder {
    
        @Override
        protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
            if (decodeToString(msg)) {
                return super.decode(ctx, channel, msg);
            }
            return msg;
        }
    
        public boolean decodeToString(Object msg) {
            // Add some logic here....
            return true;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have you ever created any custom action on your jqGrid? looking at this example
When using IMAP clients to access your email, the Inbox and any other user-created
I would like to know what is in your opinion the best way of
Edited Post These are the new functions that I have created using your template
This question tells how one can create directories in your resources path. Once created,
I created this fiddle that the div value changes based on your dropdown list
Thanks for your replies. First I am explaining my requirement :- I created my
Doug McCune had created something that was exactly what I needed ( http://dougmccune.com/blog/2007/05/10/analyze-your-actionscript-code-with-this-apollo-app/ )
I'm completely stuck and need your help... I've created a webservice stub with jaxb
In Drupal you can create your own nodetype in a custom module. Doing this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.