从java中的缓冲区读取多个值(数据类型)

时间:2015-02-23 08:02:47

标签: java buffer server decoder mina

我有一个IOBuffer,它接收一个包含两种数据类型(Object和Long)的InputBuffer。我无法一起阅读这两种数据类型。

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;
}

该功能不起作用,我无法读取缓冲区。

0 个答案:

没有答案