Does ChannelBufferInputStream within ReplayingDecoder work?

Daniel Ferber dffforum at gmail.com
Sat Jul 17 11:32:16 EDT 2010


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 ...;
	}

}

-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Does-ChannelBufferInputStream-within-ReplayingDecoder-work-tp5306217p5306217.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list