You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Aviator <av...@hotmail.com> on 2008/02/28 02:54:31 UTC

Basic Development Question

Hello  I'm somewhat new to MINA. Currently using V2.0 on Win XP. I was wondering what the correct approach would be for trying to do the following:

I have a simple server which accepts client connections (very much like the one in the MINA v2.0 Quick Start Guide). Suppose some event is triggered within the server in a separate event thread (from the threads managing the client sessions). Suppose this event is time based (happens everyday at 12:00pm) and is a simple message which is to be sent to a specific client saying 'Lunch Time'. What is the correct approach needed for this event thread to contact the appropriate client session to send the message 'Lunch Time'? Is it as simple as the event thread performing a session.write(aObject) for the appropriate client or is there some more amazing way to achieve this? For example, can the event thread inform the client session that there is a message which needs to be sent and let the client session's thread actually do the write?

Thanks

_________________________________________________________________


Re: Basic Development Question

Posted by Mark Webb <el...@gmail.com>.
You could also take advantage of the IoService.broadcast(Object) method.


On Thu, Feb 28, 2008 at 3:31 AM, Maarten Bosteels
<mb...@gmail.com> wrote:
> Hello,
>
>
>  On Thu, Feb 28, 2008 at 2:54 AM, Aviator <av...@hotmail.com> wrote:
>
>  >
>  > Hello  I'm somewhat new to MINA. Currently using V2.0 on Win XP. I was
>  > wondering what the correct approach would be for trying to do the following:
>  >
>  > I have a simple server which accepts client connections (very much like
>  > the one in the MINA v2.0 Quick Start Guide). Suppose some event is
>  > triggered within the server in a separate event thread (from the threads
>  > managing the client sessions). Suppose this event is time based (happens
>  > everyday at 12:00pm) and is a simple message which is to be sent to a
>  > specific client saying 'Lunch Time'. What is the correct approach needed for
>  > this event thread to contact the appropriate client session to send the
>  > message 'Lunch Time'? Is it as simple as the event thread performing a
>  > session.write(aObject) for the appropriate client
>
>
>  yes, that should work.
>
>
>
>
>  > or is there some more amazing way to achieve this? For example, can the
>  > event thread inform the client session that there is a message which needs
>  > to be sent and let the client session's thread actually do the write?
>
>
>  I don't think there is a mechanism like that. And I think the first approach
>  is easier, no ?
>
>  regards,
>  Maarten
>
>  >
>  >
>  > Thanks
>  >
>  > _________________________________________________________________
>  >
>  >
>



-- 
--------------------------------
Talent hits a target no one else can hit; Genius hits a target no one
else can see.

Re: Basic Development Question

Posted by Maarten Bosteels <mb...@gmail.com>.
Hello,

On Thu, Feb 28, 2008 at 2:54 AM, Aviator <av...@hotmail.com> wrote:

>
> Hello  I'm somewhat new to MINA. Currently using V2.0 on Win XP. I was
> wondering what the correct approach would be for trying to do the following:
>
> I have a simple server which accepts client connections (very much like
> the one in the MINA v2.0 Quick Start Guide). Suppose some event is
> triggered within the server in a separate event thread (from the threads
> managing the client sessions). Suppose this event is time based (happens
> everyday at 12:00pm) and is a simple message which is to be sent to a
> specific client saying 'Lunch Time'. What is the correct approach needed for
> this event thread to contact the appropriate client session to send the
> message 'Lunch Time'? Is it as simple as the event thread performing a
> session.write(aObject) for the appropriate client


yes, that should work.



> or is there some more amazing way to achieve this? For example, can the
> event thread inform the client session that there is a message which needs
> to be sent and let the client session's thread actually do the write?


I don't think there is a mechanism like that. And I think the first approach
is easier, no ?

regards,
Maarten

>
>
> Thanks
>
> _________________________________________________________________
>
>