How to handle request / response

Jonathan Arnold jdarnold at buddydog.org
Mon Jul 11 11:35:41 EDT 2011


On Mon, 11 Jul 2011 06:16:54 -0700
<Michael.Newcomb at gdc4s.com> wrote:

> Can you be a little more specific? Perhaps starting with what you are
> sending and what you are expecting in return.

In the handleUpstream override in the RequestResonseChannelHandler,
there is this code:

    if (event instanceof MessageEvent)
    {
      MessageEvent message = (MessageEvent) event;

      if (message.getMessage() instanceof Response)
      {
        Request request =
      requests.remove(((Response)message.getMessage()).getRequestId());

        assert request != null;

        request.setResponse(message);
      }
      else
      {
        context.sendUpstream(event);
      }
    }

I tried for many hours to get message.getMessage() to return my class
of message instead of HttpMessage. I tried all kinds of extends and
interfaces to no avail. In the sample code you sent out, you had:

 public interface Response
 {
   long getRequestId();
 }

I assume you must be inserting something into the pipeline to decode
into this. I'm trying to use the RtspEncoder / RtspDecoder so maybe my
problem is with those classes. I want to extend it to return back my
own RtspResponse that has an Id (I call it a sequence number). But if I
override createMessage I can't "force" it to return my
RtspResponseMessage and still get the parsing of the
RtspResponseDecoder.

-- 
Jonathan Arnold        Webstream: http://hieronymus.soup.io

Talent wins games, but team work and intelligence wins championships.
Michael Jordan



More information about the netty-users mailing list