Niklas Therning wrote:
you'd have to do is to make sure you
register your PongEncoder (which must implement MessageEncoder of
course) with the DemuxingProtocolCodecFactory you use in #1. When your
IoHandler receives a Ping message your write back a Pong message. MINA
will take care of invoking the PongEncoder.
Have a look at the sumup example. It's up to date and demonstrates how
to use the MessageEncoder/MessageDecoder stuff.
Got it, thx. (I wish you used the apache-commons-chain for your cor).
It now makes sense, thx.
No, there is no need for another IoHandler.
B. If from the ProtocolHandler messageReceived I want to call the
PongEncoder ... it does not have the "out" argument. that encoder needs?
To write the Pong response you just call
Pong pong = new Pong(...);
session.write( pong );
in your IoHandler's messageReceived method.
OK, but you said to do it in the factory above, and not to create
another IoHandler, so I will use Factory, right?
So how to code the getMessageTypes()
It should return a Set containing the message classes your
MessageEncoder can encode. In your case:
public Set getMessageTypes()
{
Set types = new HashSet();
types.add( Pong.class );
return types;
}
HTH
So I have no idea what Pong is?
The message I write in encode method of Encoder and it makes a buffer
where I add what message should be and then I write it.
What does Pong class have in it?
In SumUp example it's a bean. In my case a mina server is talking to a C
litle edian embeded HW device. And does not have the matching
structres we have in java, so I can only make a stream.
So if I get some help to get around this message type hack, I may be OK.
tia,
.V