Does ChannelBufferInputStream within ReplayingDecoder work?
"이희승 (Trustin Lee)"
trustin at gmail.com
Thu Aug 26 00:34:19 EDT 2010
Hi Daniel,
I don't see a problem. If you experience a problem, please let me know,
because it might be a bug.
BTW, there's a way to read an UTF-8 string without ChannelBufferInputStream:
int len = buf.readUnsignedShort();
String str = buf.readSlice(len).toString(CharsetUtil.UTF_8);
HTH,
Trustin
On 07/18/2010 12:32 AM, Daniel Ferber wrote:
>
> Hi,
>
> I would like to ask if there is an issue on using ChannelBufferInputStream
> within a ReplayingDecoder. Will this work as expected, or am I missing
> something?
>
> It happens that the buffer contains UTF encoded strings that were written
> with a DataOutputStream. The strings will guide how to decode the buffer
> into a message object (dont blame for this design...).
>
> The only solution I found to easily read UTF string was though
> ChannelBufferInputStream.
>
> Thanks in advance,
> Daniel Felix Ferber
>
> public class MessagesDecoder extends ReplayingDecoder<VoidEnum> {
> private static final String LoginMessageType = "login";
>
> @Override
> protected Object decode(
> ChannelHandlerContext ctx,
> Channel channel,
> ChannelBuffer buffer,
> VoidEnum state) throws Exception {
> ChannelBufferInputStream is = new ChannelBufferInputStream(buffer);
> String messageFormatType = is.readUTF();
> if (LoginMessageType.equals(messageFormatType)) {
> ...
> } ...
> return ...;
> }
>
> }
>
--
what we call human nature in actuality is human habit
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 293 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100826/f6f81e1c/attachment.bin
More information about the netty-users
mailing list