Am 29.01.2012 01:18, schrieb Emmanuel Lecharny:
On 1/29/12 12:49 AM, Bjoern Haverland wrote:
Am 29.01.2012 00:10, schrieb Emmanuel Lecharny:
On 1/28/12 11:35 PM, Björn Haverland wrote:
Hi @all,

i?m new to mina so a big hello to all of you ;)

So i have also a question. I?m searching for a more detailed protocollcodecfilter tutorial. The one which is online is good for starting, but what do i have to do if i have more telegrams then one in each direction? I have some startbytes which indicates me which kind of telegramm will follow. Could anybody give me a hint how i could solve this?

Do you mean that you have a first byte in your message that defines the message's type ?

Yepp (2 Bytes)
So it should not be a problem. Depending on those two bytes, you will decode the following bytes knowing what they will be transformed to.

There are two important things to understand :
1) the bytes you are receiving *may* contain more than one message (once decoded) 2) the bytes you are receiving *may* not be enough to decode a full message (this is due to the possible fragmentation on TCP)

Once you understand that, decoding the bytes is pretty easy.

To deal with (1), you have to loop on the bytes until you can't decode any more message To deal with (2) is a bit more complex : you have to know the size of the bytes needed to create a full message, or the bytes must have a terminator (a special byte or set of bytes that close the message).

In any case, you can use the CumulativeProtocolDecoder to deal with those two scenarii.


Again, the Image decoder exaple given on the web site is probably the page to read.


Hi Emmanuel,

thanks for your tips. I already mentioned them. But where is struggle with, is the point, how and when do i differentiate the telegrams.

The point is, every telegram starts with these 2 bytes and ends with 2 bytes. The protocol is very rudimentary, it will always come just one telegram until the other side has confirmed the receiving. So do i have more then one protocolcodecfilter, one for every telegram or do i have one protocolcodecfilter where i have to wait for the bytes and then first read out the first 2 bytes to check which telegram was sent and then build my objects with the rest of the telegram.

I´m just struggling how to use mina with more then one kind of telegram in each direction. In the tutorial was the incoming data casted to the object, because there was only this one telegram which represents this one kind of object. But what do i have to do if i have more telegrams with more kinds of objects. Is there may be a tutorial available, which extends the Image decoder tutorial?

Thank you very much

Björn



Reply via email to