A small enhancement to ReplayingDecoder
"이희승 (Trustin Lee)"
trustin at gmail.com
Tue Nov 9 02:12:36 EST 2010
Hi Bruno,
Same thing can be achieved by using checkpoint(enum) and a counter
member variable, no?
public class MyDecoder extends ReplayingDecoder {
int nParams;
public void decode (...) {
switch (state) {
case PARAM_CNT:
nParams = ...;
checkpoint(PARAM_SIZE);
case PARAM_SIZE:
param = new byte[...];
checkpoint(PARAM_VALUE);
case PARAM_VALUE:
params.add(...);
if (this.params.size() >= this.nParams) {
checkpoint(PARAM_CNT);
} else {
checkpoint(PARAM_SIZE);
}
break;
}
}
}
Bruno de Carvalho wrote:
> Hey y'all,
>
>
> Since I've subscribed to this mailing list I've seen at least a couple
> of some people struggling with ReplayingDecoder to handle complex
> message structures, mainly when integrating with legacy protocols where
> the message structure is dynamic, sometimes even with repeating fields.
>
> I've had such an experience recently and I came up with this little
> helper.
>
> http://bruno.factor45.org/blag/2010/08/21/an-enhanced-version-of-replayingdecoder-for-netty/
>
> Hope this helps someone out there as well!
>
>
> Cheers,
> Bruno
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
Trustin Lee - http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 290 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20101109/39baa422/attachment.bin
More information about the netty-users
mailing list