Example usage for io.netty.buffer ByteBuf readLong

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

Introduction

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

Prototype

public abstract long readLong();

Source Link

Document

Gets a 64-bit integer at the current readerIndex and increases the readerIndex by 8 in this buffer.

Usage

From source file:io.hydramq.core.type.converters.PartitionIdConverter.java

License:Open Source License

@Override
public PartitionId read(ConversionContext context, ByteBuf buffer) {
    return PartitionId.create(new UUID(buffer.readLong(), buffer.readLong()));
}

From source file:io.hydramq.core.type.converters.PartitionInfoConverter.java

License:Open Source License

@Override
public PartitionInfo read(final ConversionContext context, final ByteBuf buffer) {
    return new PartitionInfo(buffer.readLong(), buffer.readLong());
}

From source file:io.hydramq.core.type.converters.UUIDConverter.java

License:Open Source License

@Override
public UUID read(ConversionContext context, ByteBuf buffer) {
    return new UUID(buffer.readLong(), buffer.readLong());
}

From source file:io.hydramq.core.type.converters.WriteCursorRequestConverter.java

License:Open Source License

@Override
protected WriteCursorRequest readObject(ConversionContext context, int correlationId, ByteBuf buffer) {
    return new WriteCursorRequest(correlationId, context.read(PartitionId.class, buffer),
            context.read(String.class, buffer), buffer.readLong());
}

From source file:io.servicecomb.foundation.vertx.server.TcpParser.java

License:Apache License

protected void onParse(Buffer buffer) {
    switch (status) {
    case TCP_HEADER:
        ByteBuf buf = buffer.getByteBuf();
        if (!firstNEqual(TCP_MAGIC, buf.array(), TCP_MAGIC.length)) {
            reset();//from  w  ww . jav  a 2s  .  c om
            return;
        }

        buf.skipBytes(TCP_MAGIC.length);
        msgId = buf.readLong();
        totalLen = buf.readInt();
        headerLen = buf.readInt();

        if (totalLen == 0) {
            onReadOnePackage(null, null);
            return;
        }

        parser.fixedSizeMode(totalLen);
        status = ParseStatus.TCP_PAYLOAD;
        break;

    case TCP_PAYLOAD:
        Buffer headerBuffer = buffer.slice(0, headerLen);
        Buffer bodyBuffer = buffer.slice(headerLen, buffer.length());
        onReadOnePackage(headerBuffer, bodyBuffer);
        break;

    default:
        break;
    }
}

From source file:io.servicecomb.transport.highway.TestHighwayClient.java

License:Apache License

@Test
public void testCreateLogin() throws Exception {
    ProtobufCompatibleUtils.init();//from w ww .java2  s.c  o  m

    HighwayClientConnection connection = new HighwayClientConnection(null, null, "highway://127.0.0.1:7890",
            null);
    TcpOutputStream os = connection.createLogin();
    ByteBuf buf = os.getBuffer().getByteBuf();

    byte[] magic = new byte[TcpParser.TCP_MAGIC.length];
    buf.readBytes(magic);
    Assert.assertArrayEquals(TcpParser.TCP_MAGIC, magic);
    Assert.assertEquals(os.getMsgId(), buf.readLong());

    int start = TcpParser.TCP_HEADER_LENGTH;
    int totalLen = buf.readInt();
    int headerLen = buf.readInt();
    Buffer headerBuffer = os.getBuffer().slice(start, start + headerLen);
    int end = start + totalLen;
    start += headerLen;
    Buffer bodyBuffer = os.getBuffer().slice(start, end);

    RequestHeader header = RequestHeader.readObject(headerBuffer, connection.getProtobufFeature());
    Assert.assertEquals(MsgType.LOGIN, header.getMsgType());

    LoginRequest login = LoginRequest.readObject(bodyBuffer);
    Assert.assertEquals(HighwayTransport.NAME, login.getProtocol());
}

From source file:it.kytech.smartccraft.network.message.MessageTileChargeStation.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();
    this.orientation = buf.readByte();
    this.state = buf.readByte();
    int customNameLength = buf.readInt();
    this.customName = new String(buf.readBytes(customNameLength).array());
    if (buf.readBoolean()) {
        this.ownerUUID = new UUID(buf.readLong(), buf.readLong());
    } else {//  w  ww.  ja v  a2s . c o m
        this.ownerUUID = null;
    }
    this.status = buf.readByte();
}

From source file:it.kytech.smartccraft.network.message.MessageTileEntitySCC.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();
    this.orientation = buf.readByte();
    this.state = buf.readByte();
    int customNameLength = buf.readInt();
    this.customName = new String(buf.readBytes(customNameLength).array());
    if (buf.readBoolean()) {
        this.ownerUUID = new UUID(buf.readLong(), buf.readLong());
    } else {/*from   w  w  w  . j a va 2 s  .  c o m*/
        this.ownerUUID = null;
    }
    fromBytesChild(buf);
}

From source file:ivorius.ivtoolkit.tools.IvNBTHelper.java

License:Apache License

public static long[] readNBTLongs(String id, NBTTagCompound compound) {
    if (compound.hasKey(id)) {
        ByteBuf bytes = Unpooled.copiedBuffer(compound.getByteArray(id));
        long[] longs = new long[bytes.capacity() / 8];
        for (int i = 0; i < longs.length; i++)
            longs[i] = bytes.readLong();
        return longs;
    }//from   w  w  w .  j a va 2 s .  co m

    return null;
}

From source file:jayavery.geomastery.packets.CPacketContainer.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {

    this.slot = buf.readInt();
    this.stack = ByteBufUtils.readItemStack(buf);
    this.birthTime = buf.readLong();
}