Example usage for io.netty.buffer ByteBuf writeShort

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

Introduction

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

Prototype

public abstract ByteBuf writeShort(int value);

Source Link

Document

Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.

Usage

From source file:alluxio.network.protocol.RPCBlockReadResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mBlockId);/* w w  w  .ja  va2  s  .  c o m*/
    out.writeLong(mOffset);
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
    // The actual payload is not encoded here, since the RPCMessageEncoder will transfer it in a
    // more efficient way.
}

From source file:alluxio.network.protocol.RPCBlockWriteResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mSessionId);//  w w  w  . j av a  2s  . c o m
    out.writeLong(mBlockId);
    out.writeLong(mOffset);
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
}

From source file:alluxio.network.protocol.RPCErrorResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeShort(mStatus.getId());
}

From source file:alluxio.network.protocol.RPCFileReadResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mTempUfsFileId);// w w  w.  j  a v a 2  s  .  c  o  m
    out.writeLong(mOffset);
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
    // The actual payload is not encoded here, since the RPCMessageEncoder will transfer it in a
    // more efficient way.
}

From source file:alluxio.network.protocol.RPCFileWriteResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mTempUfsFileId);/*from ww w  .  j a  v  a  2  s  .  c o m*/
    out.writeLong(mOffset);
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
}

From source file:appeng.core.sync.packets.PacketPartialItem.java

License:Open Source License

public PacketPartialItem(final int page, final int maxPages, final byte[] buf) {

    final ByteBuf data = Unpooled.buffer();

    this.pageNum = (short) (page | (maxPages << 8));
    this.data = buf;
    data.writeInt(this.getPacketID());
    data.writeShort(this.pageNum);
    data.writeBytes(buf);//  w  w w  .ja v  a2s.co m

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketProgressBar.java

License:Open Source License

public PacketProgressBar(final int shortID, final long value) {
    this.id = (short) shortID;
    this.value = value;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeShort(shortID);
    data.writeLong(value);/*  w  w w.  j  ava2  s  .  co m*/

    this.configureWrite(data);
}

From source file:appeng.parts.CableBusContainer.java

License:Open Source License

public void writeToStream(final ByteBuf data) throws IOException {
    int sides = 0;
    for (int x = 0; x < 7; x++) {
        final IPart p = this.getPart(AEPartLocation.fromOrdinal(x));
        if (p != null) {
            sides |= (1 << x);// w w  w  .  j  a v a 2 s.  co m
        }
    }

    data.writeByte((byte) sides);

    for (int x = 0; x < 7; x++) {
        final IPart p = this.getPart(AEPartLocation.fromOrdinal(x));
        if (p != null) {
            final ItemStack is = p.getItemStack(PartItemStack.NETWORK);

            data.writeShort(Item.getIdFromItem(is.getItem()));
            data.writeShort(is.getItemDamage());

            p.writeToStream(data);
        }
    }

    this.getFacadeContainer().writeToStream(data);
}

From source file:appeng.util.item.AEItemStack.java

License:Open Source License

@Override
void writeIdentity(final ByteBuf i) throws IOException {
    i.writeShort(Item.REGISTRY.getIDForObject(this.getDefinition().getItem()));
    i.writeShort(this.getItemDamage());
}

From source file:appeng.util.item.AEStack.java

License:Open Source License

private void putPacketValue(final ByteBuf tag, final long num) {
    if (num <= 255) {
        tag.writeByte((byte) (num + Byte.MIN_VALUE));
    } else if (num <= 65535) {
        tag.writeShort((short) (num + Short.MIN_VALUE));
    } else if (num <= 4294967295L) {
        tag.writeInt((int) (num + Integer.MIN_VALUE));
    } else {//from   ww  w  .  j  a va2  s  . c  o m
        tag.writeLong(num);
    }
}