Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server in Apache Mina

I found some code on this link http://www.techbrainwave.com/?p=912 which describes how to set up a client server architecture using apache mina. However, in the example provided it is only one-way communication (from client to server). Does anyone know how to modify this in order to obtain two-way communication?

like image 764
g90 Avatar asked Mar 30 '26 18:03

g90


1 Answers

If you want the server to reply to the client message, you need to do it in the IoHandler of the server :

@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 */); 
}
like image 190
Julien Vermillard Avatar answered Apr 02 '26 20:04

Julien Vermillard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!