Hi everyone,
I've been struggling with Mina for 3 weeks now.
I want to chain 2 codecs and i couldn't find anything useful on the forum
so i decided to send this post.
What i am trying to do is : write a multi layer protocol.
In other terms, i am trying to do this :
+---------------------+
| client/server |
+---------------------+
|
segment
|
+---------------------+
| codec1 |
+---------------------+
|
Packet
|
+---------------------+
| codec2 |
+---------------------+
|
bytes
|
+---------------------+
| net |
+---------------------+
So, as you see there are 2 types of messages : Segment (a POJO that contains
just an int for my testing) and the Packet (a POJO as well that
is aimed
at representing a packet containing one or many segments and adding a header
and tail field).
To do this, i am using a 'DemuxingProtocolCodecFactory' and this should
provide 2 encoders and 2 decoders (for the 2 types of messages:
segment and packet).
+ The first problem is that the 'DemuxingProtocolCodecFactory' doesn't allow
me to register 2 encoders and 2 decoders :
for 1 message encoder and decoder its okey but not for 2 encoders and
decoders.
+ The second problem (i have) :
i know how to encode and decode a packet but not for the 'segment'.
a packet is : +--------------------------------+
| header | segments | crc | tail |
+--------------------------------+
all the parts are represented as bytes (there is a method in the segment
that provides the int value as a byte [] like this : byte [] datat=
Mysegment.getValueAsbyte() ).
The problem is that i want the clients to manipulate only Segments so that
the session.write(segment_to_send) and that the segment_to_send is
encoded correctly into a packet and a packet into bytes and bytes sent over
the net.
When received this by the a server i want the serverside to be able to :
transmit the incoming bytes into an object of type 'packet' and that
a segment is extracted from the packet object and the segment is delivered
to the server.
But, i just can't do this,
Any help would be very appreciated,
Thx.