Hi Emit,
>
> Thanks to Alexey's suggestion on moving to 2.0 & Connections, I
> now have some experimental framework up and running based on the
> LifeCycleExample demo.
Glad to hear that :)
> My binary protocol is basically just a stream of TLVs; an id
> byte, length of data, and the data itself... nothing special.
>
> To separate out these discrete sets of bytes, in normal java/c I
> just reconstruct each packet by first reading the length field
> and reading the next n bytes to fill out the buffer, waiting for
> the data if necessary....
>
> Back to grizzly 2.0: I see that the processing stage starts at
> handleRead... The ctx.getMessage() gets a Buffer of the next
> set of bytes, but it is obviously not guaranteed to be a fully
> constructed "message" as I would like it. It could be cut off,
> queued up, etc.
Right.
> What is the best "grizzly 2.0" way to cut up the incoming stream
> into these logical packets of data, hopefully without editting
> the grizzly internal classes? I guess I can just aggregate
> these getMessage Buffers myself after the handleReads but in that
> case I don't see a reason to use this framework with all the
> overhead involved.
You'd probably need to implement own Transformer for encoding/decoding
Buffer to your custom protocol message. It's probably the only one
thing you'll have to do.
General framework knows nothing about your protocol, so it's bad news,
but you'll need to implement this yourself :)
Currently writing Transformer is not as simple as I would like to see
that. John is working on Streams filter, which will help a lot to make
parsing/transformation process much easier.
You can take a look at the Filter example [1] and how it is used [2].
> I think it would be helpful if you could show how to build upon
> the example EchoFilter to only echo back lines of text. i.e.
> '\n' would mark end of message, and a string would be the logical
> unit. (so even from windows telnet it will only echo back on new
> line, instead of on each character typed)
Unfortunately there is not such an example :( But you can try to
implement your own Transformer, based on example I gave. If you'll
have any question on this - pls. let us know.
Thanks.
WBR,
Alexey.
[1]
https://grizzly.dev.java.net/source/browse/grizzly/branches/2dot0/modules/grizzly/src/test/java/org/glassfish/grizzly/util/UTFStringFilter.java?view=markup
[2]
https://grizzly.dev.java.net/source/browse/grizzly/branches/2dot0/modules/grizzly/src/test/java/org/glassfish/grizzly/FilterChainTest.java?view=markup
> Regards,
> -Emit
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>