Le 17/03/15 22:29, Abeer Al-Anazi a écrit :
> Hi everyone.
> I want to send value from server to client, I call function
> recevieFromSuperController in my class and send the value via it.
> serverHandler handler = new serverHandler();
> handler.recevieFromSuperController(requiedSwitch);
> in server handler:
> private SocketAddress SwitchId ;
> public void recevieFromSuperController(SocketAddress s)
> {
> this.SwitchId = s;
> System.out.println(SwitchId); // switchId = the value that I want
> to send.
> }
> when I want to write the value to the client, the value is equal null !
> public void sessionOpened(final IoSession session) throws Exception
> {
> System.out.println(SwitchId); // switchId = null here
> session.write(SwitchId);
> }
>
> can anyone tell me why the value become null?
Well, you are trying to print a value which is not already loaded with
anything when the session is created. I have no idea what the
recevieFromSuperControllermethod does, but it's for sure not a MINA
method, so my guess is that it's getting called after the session is
opened.