mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: Send from server To Multi-Client
Date Tue, 14 Apr 2015 06:43:37 GMT
Le 14/04/15 03:50, Abeer Al-Anazi a écrit :
> Hi
> I have server connects with two client c1, c2 via MINA. I want to send some
> data from the server to c1 only. BUT when I do that, the server send the
> data to BOTH clients c1 and c2. I use different port number 9999 to client
> c1, 7777 to client c2, and I put one serverHandler for both.  below is a
> function in serverHandler that send data to clients.
>
> @Override
>     public void sessionOpened(final IoSession session) throws Exception
>     {
>
>         new Timer().schedule(
>                 new TimerTask() {
>                     @Override
>                     public void run() {
>                         if (SwitchId != null){
>
> session.getConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
>                         session.setAttribute("Values: ");
>                         session.write(SwitchId);
>                         }
>                     }
>                 },
>                30000
>             );
>
>             }
>
If this event is present in your serverHandler, then obviously you will
have as many instances of your time as you have connections, and the
SwitchId value will be sent to any client connecting to the server.

What's the problem here ?

Mime
View raw message