Decoders

César Fernando Henriques cesar at alttab.com.ar
Mon May 25 16:31:15 EDT 2009


Hi Trustin,

On Mon, May 25, 2009 at 6:12 AM, Trustin Lee <tlee at redhat.com> wrote:
> Yes, it's pretty easy, and it's great that you like Netty.
>
> BTW, could you share us how you did what you wanted?  What I can think of is to insert a custom handler right after the HttpRequestDecoder (or HttpResponseDecoder) to transform HttpMessage into a new user-defined type.

Yes, that is the way I did. I have added a CustomChannel after
HttpRequestDecoder/HttpResponseDecoder to wrap the HttpMessage into
Custom aplication Objects.

>
> I thought it might be interesting if the type of HttpMessage.content is not ChannelBuffer but Object.  Then it could make the transformation much easier.  However, a user will always have to down-cast.

I don't think It would be useful ( at least for my requirements), I'm
adding more channels to abstract my application from http protocol,
so my first CustomHandler will replace the HttpMessage and pass a new
object to the next Channel.

Why isn't there a method to replace MessageEvent.message Object? So I
can replace the message in my Channel. Rigth now  I get the
DefaultHttpRequest and wrap it in a custom app object and pass to the
next Channel to process application messages in a friendly way, I'
doing something like this:

       public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
			throws Exception {
                // detect http message type and wrap it
                ...
                // pass ti the next handler
		UpstreamMessageEvent me = new UpstreamMessageEvent(ctx.getChannel(),
wrappedObject,
				ctx.getChannel().getRemoteAddress());
		
		super.messageReceived(ctx, me);
	}

Do you think it's viable to add a setMessage to MessageEvent so I
don't have to create another UpstreamMessageEvent ?

Another question, is there an implementation of CompressionChannel?

Thanks,

Cesar.-

>
> Thanks,
>
> On Fri, 22 May 2009 06:35:46 +0900, César Fernando Henriques <cesar at alttab.com.ar> wrote:
>
>> I got it... pretty easy... I like Netty.
>>
>> Thanks
>>
>> 2009/5/21 César Fernando Henriques <cesar at alttab.com.ar>:
>>> Guys, is there any way in what I can Decode a message on top of
>>> HttpRequestDecode? I mean can I add a ChannelHandler that execute
>>> after HttpRequestDecoder or should I create a subclass of
>>> HttpRequestDecoder to decode my object? In that is the case how can I
>>> decode differents types of Http Messages?
>>>
>>> I'm looking to create a custom protocol on top of http, maybe should I
>>> create a utility object that return custom RequestMessages and done
>>> but the first approach seems to be more elegant.
>>>
>>> Regards
>>>
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>
>
> --
> - Trustin Lee, http://gleamynode.net/
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>




More information about the netty-users mailing list