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?
Asked
Active
Viewed 2,686 times
3
-
This link is now dead and points to a parked domain. I believe the same example can be found on the Mina site. – Mike Stoddart Apr 27 '17 at 20:29
1 Answers
5
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 */);
}

Julien Vermillard
- 2,945
- 1
- 18
- 18
-
ok thanks that worked. I then tried to shift the client code to android (I'm using motodev). However, the program stumbles upon this line: IoConnector connector = new NioSocketConnector(); with the error : java.lang.NoClassDefFoundError: org.apache.mina.transport.socket.nio.Niosocketconnector. What do you think can be the cause? – g90 Apr 08 '11 at 12:47
-