You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by arati <ar...@unnat-e.com> on 2008/05/16 13:35:06 UTC
Using DemuxingIOHandler
Hi All,
I want server and client both to handle multiple messages.
For example say AddMessage, SubtractMessage, AddResultMessage and
SubtractResultMessage.
When client sends AddMessage it receives AddResultMessage and similar for
SubtractMessage.
I am using mina 2.0M1.
According to my understanding I need to write message, encoder, decoder and
handler classes for these messages.
As both the client and server should be able to handle different messages, I
have extended from
DemuxingIOHandler for client and server main handlers.
I have added the encoders and decoders to DemuxingProtocolCodecFactory and
added this to filter chain.
Now in these main handlers I need to add handlers for individual messages.
So that is done by:
In server side handler
addReceivedMessageHandler(AddMessage.class, new AddMessageHandler());
addReceivedMessageHandler(SubtractMessage.class, new
SubtractMessageHandler());
addSentMessageHandler(AddResultMessage.class, new
AddResultMessageHandler());
addSentMessageHandler(SubtractResultMessage.class, new
SubtractResultMessageHandler());
But on server side I don't want to do anything in the
Add/SubtractResultMessageHandler's handleMessage() method.
So is there any way to avoid adding these handlers?
If I don't add these handler then it gives exception.
On the client side also I need to do same thing.
There I don't want to use the Add/Subtract message handler's handleMessage()
method.
In general is there any way to avoid adding handlers for sent messages?
If not, then does that mean that I need to write different messageHandlers
for client and server for the same messages?
Thanks in advance.
RE: Using DemuxingIOHandler
Posted by arati <ar...@unnat-e.com>.
Thanks Trustin.
That's exactly what I wanted.
I should have gone through the API document first.
Thanks.
-----Original Message-----
From: 이희승 (Trustin Lee) [mailto:trustin@gmail.com]
Sent: Monday, May 19, 2008 08:15
To: users@mina.apache.org
Subject: Re: Using DemuxingIOHandler
You could specify MessageHandler.NOOP in that case?
On Fri, 16 May 2008 20:35:06 +0900, arati <ar...@unnat-e.com> wrote:
> Hi All,
>
> I want server and client both to handle multiple messages.
>
> For example say AddMessage, SubtractMessage, AddResultMessage and
> SubtractResultMessage.
>
> When client sends AddMessage it receives AddResultMessage and similar for
> SubtractMessage.
>
>
> I am using mina 2.0M1.
>
> According to my understanding I need to write message, encoder, decoder
> and
> handler classes for these messages.
>
> As both the client and server should be able to handle different
> messages, I
> have extended from
>
> DemuxingIOHandler for client and server main handlers.
>
> I have added the encoders and decoders to DemuxingProtocolCodecFactory
> and
> added this to filter chain.
>
> Now in these main handlers I need to add handlers for individual
> messages.
>
>
> So that is done by:
>
> In server side handler
>
>
> addReceivedMessageHandler(AddMessage.class, new AddMessageHandler());
>
> addReceivedMessageHandler(SubtractMessage.class, new
> SubtractMessageHandler());
>
> addSentMessageHandler(AddResultMessage.class, new
> AddResultMessageHandler());
>
> addSentMessageHandler(SubtractResultMessage.class, new
> SubtractResultMessageHandler());
>
>
> But on server side I don't want to do anything in the
> Add/SubtractResultMessageHandler's handleMessage() method.
>
> So is there any way to avoid adding these handlers?
>
> If I don't add these handler then it gives exception.
>
>
> On the client side also I need to do same thing.
>
> There I don't want to use the Add/Subtract message handler's
> handleMessage()
> method.
>
>
> In general is there any way to avoid adding handlers for sent messages?
>
> If not, then does that mean that I need to write different
> messageHandlers
> for client and server for the same messages?
>
>
> Thanks in advance.
>
>
>
>
--
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/
Re: Using DemuxingIOHandler
Posted by "이희승 (Trustin Lee)" <tr...@gmail.com>.
You could specify MessageHandler.NOOP in that case?
On Fri, 16 May 2008 20:35:06 +0900, arati <ar...@unnat-e.com> wrote:
> Hi All,
>
> I want server and client both to handle multiple messages.
>
> For example say AddMessage, SubtractMessage, AddResultMessage and
> SubtractResultMessage.
>
> When client sends AddMessage it receives AddResultMessage and similar for
> SubtractMessage.
>
>
> I am using mina 2.0M1.
>
> According to my understanding I need to write message, encoder, decoder
> and
> handler classes for these messages.
>
> As both the client and server should be able to handle different
> messages, I
> have extended from
>
> DemuxingIOHandler for client and server main handlers.
>
> I have added the encoders and decoders to DemuxingProtocolCodecFactory
> and
> added this to filter chain.
>
> Now in these main handlers I need to add handlers for individual
> messages.
>
>
> So that is done by:
>
> In server side handler
>
>
> addReceivedMessageHandler(AddMessage.class, new AddMessageHandler());
>
> addReceivedMessageHandler(SubtractMessage.class, new
> SubtractMessageHandler());
>
> addSentMessageHandler(AddResultMessage.class, new
> AddResultMessageHandler());
>
> addSentMessageHandler(SubtractResultMessage.class, new
> SubtractResultMessageHandler());
>
>
> But on server side I don't want to do anything in the
> Add/SubtractResultMessageHandler's handleMessage() method.
>
> So is there any way to avoid adding these handlers?
>
> If I don't add these handler then it gives exception.
>
>
> On the client side also I need to do same thing.
>
> There I don't want to use the Add/Subtract message handler's
> handleMessage()
> method.
>
>
> In general is there any way to avoid adding handlers for sent messages?
>
> If not, then does that mean that I need to write different
> messageHandlers
> for client and server for the same messages?
>
>
> Thanks in advance.
>
>
>
>
--
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/