Hi Andi,

On Nov 22, 2007 8:00 PM, superandi <[EMAIL PROTECTED]> wrote:
>
> Hi there Mina-Pros,
>
> before discovering Mina I did the following:
>
> I Started a Java ServerSocket to accept connections. I remembered the
> accepted connection and waited for a new one. At server start i spawned a
> number of Worker threads that:
>
> - checked if data was available FROM each of the sockets FOR my application
> logic.
> - checked if data was available FOR one of the sockets FROM my application
> logic.
>
> Thus i put the worker thread in charge of getting data from the
> socket->logic and vice versa.
>
> Then i discovered MINA and I'd like to use it since its tested and stable
> and works. But can I write a class (extending IoHandlerAdapter???) that not
> only calls "messageReceived" when data is available from the Socket but also
> periodically calls something like "shouldIsendSomeMessage" that can return
> an Object to be processed by my protocolFilter or null if nothing is to be
> sent out.
>
> Of course i could start some threads to do exactly this, but i think it
> might be wiser to use the worker threads that mina already provides for this
> task. Is this possible at all? Does it make sense?

You might want to use sessionIdle event if the message is supposed to
be sent only when the session is idle (i.e. no data transmission for a
certain amount of time).  Otherwise, I'd recommend you to use
ScheduledExecutorService.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to