Example usage for io.netty.buffer ByteBuf writeLong

List of usage examples for io.netty.buffer ByteBuf writeLong

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeLong.

Prototype

public abstract ByteBuf writeLong(long value);

Source Link

Document

Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.

Usage

From source file:se.sics.nstream.storage.cache.KHintSummarySerializer.java

License:Open Source License

@Override
public void toBinary(Object o, ByteBuf buf) {
    KHint.Summary obj = (KHint.Summary) o;
    buf.writeLong(obj.lStamp);
    buf.writeInt(obj.blocks.size());/*from  w ww  . j  ava2 s.  com*/
    for (Integer block : obj.blocks) {
        buf.writeInt(block);
    }
}

From source file:se.sics.p2ptoolbox.serialization.serializer.UUIDSerializer.java

License:Open Source License

@Override
public ByteBuf encode(SerializationContext context, ByteBuf buf, UUID obj) throws SerializerException {
    buf.writeLong(obj.getMostSignificantBits());
    buf.writeLong(obj.getLeastSignificantBits());
    return buf;//w w  w.  j a v a2s  .c  om
}

From source file:tachyon.network.protocol.RPCBlockReadRequest.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mBlockId);
    out.writeLong(mOffset);
    out.writeLong(mLength);
}

From source file:tachyon.network.protocol.RPCBlockRequest.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    // TODO: remove this short when client also uses netty.
    out.writeShort(DataServerMessage.DATA_SERVER_REQUEST_MESSAGE);
    out.writeLong(mBlockId);
    out.writeLong(mOffset);/* ww  w.  j a  v  a  2s. c  om*/
    out.writeLong(mLength);
}

From source file:tachyon.network.protocol.RPCBlockResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    // TODO: remove this short when client also uses netty.
    out.writeShort(DataServerMessage.DATA_SERVER_RESPONSE_MESSAGE);
    out.writeLong(mBlockId);
    out.writeLong(mOffset);/* ww  w. ja va2s  .c om*/
    out.writeLong(mLength);
    // The actual payload is not encoded here, since the RPCMessageEncoder will transfer it in a
    // more efficient way.
}

From source file:therogue.storehouse.network.CGuiUpdateTEPacket.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeLong(pos.toLong());
    NetworkUtils.writeNBTTagCompoundToBuffer(buf, nbt);
}

From source file:therogue.storehouse.network.SGuiUpdateTEPacket.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeByte(item);
    buf.writeLong(pos.toLong());
    NetworkUtils.writeNBTTagCompoundToBuffer(buf, nbt);
}

From source file:util.NettyMessageEncoder.java

@Override
protected void encode(ChannelHandlerContext ctx, NettyMessage msg, List<Object> list) throws Exception {
    if (msg == null || msg.getHeader() == null)
        throw new Exception("The encode message is null");

    ByteBuf sendBuf = Unpooled.buffer();
    sendBuf.writeInt(msg.getHeader().getCrcCode());
    sendBuf.writeInt(msg.getHeader().getLength());
    sendBuf.writeLong(msg.getHeader().getSessionID());
    sendBuf.writeByte(msg.getHeader().getType());
    sendBuf.writeByte(msg.getHeader().getPriority());
    sendBuf.writeInt(msg.getHeader().getAttachment().size());

    String key = null;//from www. jav  a 2 s .co m
    byte[] keyArray = null;
    Object value = null;

    for (Map.Entry<String, Object> param : msg.getHeader().getAttachment().entrySet()) {
        key = param.getKey();
        keyArray = key.getBytes("UTF-8");
        sendBuf.writeInt(keyArray.length);
        sendBuf.writeBytes(keyArray);

        value = param.getValue();
        marshallingEncoder.encode(value, sendBuf);
    }

    key = null;
    keyArray = null;
    value = null;

    if (msg.getBody() != null) {
        marshallingEncoder.encode(msg.getBody(), sendBuf);
    } else {
        sendBuf.writeInt(0);
    }

    sendBuf.setInt(4, sendBuf.readableBytes() - 8);

}

From source file:vazkii.botania.common.entity.EntityDoppleganger.java

License:Open Source License

@Override
public void writeSpawnData(ByteBuf buffer) {
    buffer.writeInt(playerCount);//from   ww  w  .  ja v a 2 s .  c om
    buffer.writeBoolean(hardMode);
    buffer.writeLong(source.toLong());
    buffer.writeLong(bossInfoUUID.getMostSignificantBits());
    buffer.writeLong(bossInfoUUID.getLeastSignificantBits());
}