can any one tell me How can I write decode function for this encode
function?
public void encode(IoSession session, Object message, ProtocolEncoderOutput
out) throws Exception {

        IoBuffer buffer = IoBuffer.allocate(120, false);
        buffer.setAutoExpand(true);
        if (message instanceof Long )
        {
             long controllerCurrentLoad= (Long) message;
             buffer.putLong(controllerCurrentLoad);

        }

        else if ( message instanceof Object )
        {
        controllerInfo  request = (controllerInfo ) message;
        buffer.putObject(request.getControllerName());
        buffer.putObject(request.getBackupControllers());
        buffer.putLong(request.getControllerCapacity());


        }


           buffer.flip();

           out.write(buffer);





    }

My attempt is:

protected boolean doDecode(IoSession session, IoBuffer in,
ProtocolDecoderOutput out) throws Exception {
String cName =(String) in.getObject();HashMap <String, Long>
backupControllers = (HashMap<String, Long>) in.getObject();long
controllerCapacity = in.getLong();
controllerInfo request = new controllerInfo (cName, backupControllers,
controllerCapacity); // this is object data type
long    controllerCurrentLoad = in.getLong();//this is long data type
request.setControllerLoad(controllerCurrentLoad);

            out.write(request);
            return false;
    }
    }

But it does not work :\

Reply via email to