<div dir="ltr">Where is it exactly?<br><br><div class="gmail_quote">On Thu, May 13, 2010 at 4:33 AM, Johnny Luong <span dir="ltr"><<a href="mailto:johnny.luong@trustcommerce.com">johnny.luong@trustcommerce.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Shay,<br>
<br>
I think the example provided in the javadoc under Decoder Implementation<br>
is what your trying to do and provides clarity...<br>
<br>
<a href="http://docs.jboss.org/netty/3.1/api/" target="_blank">http://docs.jboss.org/netty/3.1/api/</a><br>
<br>
Best,<br>
Johnny<br>
<div><div></div><div class="h5"><br>
<br>
Shay Banon wrote:<br>
> Hi,<br>
><br>
> I have a problem and am trying to find the best solution for. In netty, I<br>
> am using a FrameDecoder that simply does the following:<br>
><br>
> protected Object decode(ChannelHandlerContext ctx, Channel channel,<br>
> ChannelBuffer buffer) throws Exception {<br>
><br>
> if (buffer.readableBytes() < 4) {<br>
> return null;<br>
> }<br>
><br>
> int dataLen = buffer.getInt(buffer.readerIndex());<br>
> if (dataLen <= 0) {<br>
> throw new StreamCorruptedException("invalid data length: " +<br>
> dataLen);<br>
> }<br>
><br>
> if (buffer.readableBytes() < dataLen + 4) {<br>
> return null;<br>
> }<br>
><br>
> buffer.skipBytes(4);<br>
><br>
> return buffer;<br>
> }<br>
><br>
> On the next handler, I use the buffer to extract the request from (and other<br>
> information). The problem I have is that something might fail and I won't<br>
> read the whole buffer. In this case, things gets corrupted for requests that<br>
> follow. Once I do read the whole buffer, things works correctly. I can<br>
> skipBytes in the size of (writerIndex - readerIndex) in case of an<br>
> exception, but then I wonder how does the built in ObjectDecoder handles<br>
> this case..., maybe I am missing something?<br>
><br>
> cheers,<br>
> shay.banon<br>
><br>
><br>
><br>
</div></div>> ------------------------------------------------------------------------<br>
><br>
> _______________________________________________<br>
> netty-users mailing list<br>
> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</blockquote></div><br></div>