On 9/10/07, Magarshak, Roman <[EMAIL PROTECTED]> wrote:
> Hi All,
>    I have the following problem:
> When connection established I add a IoSession object to different
> object, which some times needs to send a message to all connected
> sockets.
> The thing is that when I use IoSession.write(ByteBuffer) it is being
> logged but not sent.
> Do I use Mina wrong?

Are you using the same ByteBuffer instance to broadcast a message?
Then it can be a problem because ByteBuffer position will be changed
per each write.  The solution is to create duplicate buffers.  It
performs well because it doesn't copy the content of the buffer but
the position and the limit value:

ByteBuffer message = ...;;
Collection<IoSession> sessions = ...;
for (IoSession s: sessions) {
    s.write(message.duplicate());
}

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

Reply via email to