Apache Mina中的服务器

g90*_*g90 3 client apache-mina

我在此链接http://www.techbrainwave.com/?p=912上找到了一些代码,其中介绍了如何使用apache mina设置客户端服务器体系结构.但是,在提供的示例中,它只是单向通信(从客户端到服务器).有谁知道如何修改这个以获得双向通信?

小智 5

如果您希望服务器回复客户端消息,则需要在服务器的IoHandler中执行此操作:

@Override
public void messageReceived(IoSession session, Object message)
{
   logger.info("Message received in the server..");
   logger.info("Message is: " + message.toString());
   // reply to the client
   session.write( /*the reply message here */); 
}
Run Code Online (Sandbox Code Playgroud)