public void messageReceived( ProtocolSession 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.log( Level.INFO, session, "The sum: " + rm.getValue() );
session.close();
finished = true;
}
}
else