Broadcasting and Encoding

"Trustin Lee (이희승)" trustin at gmail.com
Mon Mar 8 05:40:57 EST 2010


Hi Don,

Don Park wrote:
> Hi.
> 
> While using a ChannelGroup to broadcast some JSON messages to multiple
> WebSocket channels, I ran into some design issues:
> 
> 1. Writing JSONObject to the ChannelGroup leads to JSONObject being encoded
> to WebSocketFrame once per channel which doesn't scale well (at least for my
> use case).

Yes, this is a known issue - you need to use EncoderEmbedder, as you
noticed already.

> 2. Writing WebSocketFrame to the ChannelGroup after directly encoding
> JSONObject to WebSocketFrame doesn't work because WebSocketFrame's internal
> binaryData's readerIndex is not restored, delivering the message to only the
> first channel.

This is a bug.  Let me fix it.  You'd better choose the idea #3 anyway. :)

> 3. Writing ChannelBuffer to the ChannelGroup after directly encoding
> JSONObject to ChannelBuffer forces me to duplicate code within
> WebSocketEncoder because WebSocketEncoder is designed to work within a
> pipeline and not as a utility class.
> 
> Perhaps I am overlooking something but I think ChannelGroup could use it's
> own pipeline of encoders to encode high-level objects down to ChannelBuffer
> which it knows how to handle.
> 
> Best,
> 
> Don park
> 

HTH,
Trustin

-- 
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: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100308/fcd1d820/attachment-0001.bin 


More information about the netty-users mailing list