|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
I have a questionDear my friends, I have a question in using MINA. I use 'NioDatagramConnector' to send a message to server side and use 'NioDatagramAcceptor' to receive it. In server side , I define a class 'UdpServerHandler' to handle the message. Question the function, which is called 'messageReceived', in my handler class. Can I use 'session.write()' to send a message to client? Or, I must write a connector in server side to connect the client side? Code @Override public void messageReceived(IoSession session, Object message) throws Exception { if (message instanceof LoginRequestMessage) { LoginRequestMessage m = (LoginRequestMessage) message; System.out.println(m.getUsername()); System.out.println(m.getPassword()); LoginResponseMessage resp = new LoginResponseMessage(); resp.setType(1); session.write(resp); } } The 'LoginRequestMessage' and 'LoginResponseMessage' is defined by me. I run my program. But the result is that the client don't receive the message and log displays that server really sends the message. How can I solve this problem? Thank you! _________________________________________________________________ MSN 中文网,最新时尚生活资讯,白领聚集门户。 http://cn.msn.com |
|
|
Re: I have a questionliuandy wrote:
> > Dear my friends, > > I have a question in using MINA. I use 'NioDatagramConnector' to send a message to server side and use 'NioDatagramAcceptor' to receive it. In server side , I define a class 'UdpServerHandler' to handle the message. > > Question > the function, which is called 'messageReceived', in my handler class. Can I use 'session.write()' to send a message to client? Or, I must write a connector in server side to connect the client side? > the channel is open in both ways. You should be able to read and write on the server. > Code > @Override > public void messageReceived(IoSession session, Object message) > throws Exception { > if (message instanceof LoginRequestMessage) { > LoginRequestMessage m = (LoginRequestMessage) message; > System.out.println(m.getUsername()); > System.out.println(m.getPassword()); > > LoginResponseMessage resp = new LoginResponseMessage(); > resp.setType(1); > session.write(resp); > } > } > > The 'LoginRequestMessage' and 'LoginResponseMessage' is defined by me. > > I run my program. But the result is that the client don't receive the message and log displays that server really sends the message. > > How can I solve this problem? > Does the client read the response ? -- -- cordialement, regards, Emmanuel Lécharny www.iktek.com directory.apache.org |
| Free Forum Powered by Nabble | Forum Help |