}
public void messageReceived(IoSession session, Object message) {
// server only sends ResultMessage. otherwise, we will have to identify
// its type using instanceof operator.
ResultMessage rm = (ResultMessage) message;
if (rm.isOk()) {
// server returned OK code.
// if received the result message which has the last sequence
// number,
// it is time to disconnect.
if (rm.getSequence() == values.length - 1) {
// print the sum and disconnect.
SessionLog.info(session, "The sum: " + rm.getValue());
session.close();
finished = true;
}
} else {
// seever returned error code because of overflow, etc.