Example usage for io.netty.buffer ByteBuf readInt

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

Introduction

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

Prototype

public abstract int readInt();

Source Link

Document

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

Usage

From source file:com.kaijin.AdvPowerMan.tileentities.TEChargingBench.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override/*from w  ww  . jav a2s  . c  o  m*/
public void receiveDescriptionData(int packetID, ByteBuf stream) {
    final int a;
    final boolean b;
    // try
    // {
    a = stream.readInt();
    b = stream.readBoolean();
    /*
     * } catch (IOException e) { logDescPacketError(e); return; }
     */
    chargeLevel = a;
    doingWork = b;
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}

From source file:com.kaijin.AdvPowerMan.tileentities.TEStorageMonitor.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override//from  w  w w. j a v a 2 s  .  c o  m
public void receiveDescriptionData(int packetID, ByteBuf stream) {
    final int a;
    final boolean b;
    final boolean c;
    // try
    // {
    a = stream.readInt();
    b = stream.readBoolean();
    c = stream.readBoolean();
    /*
     * } catch (IOException e) { logDescPacketError(e); return; }
     */

    chargeLevel = a;
    isPowering = b;
    blockState = c;
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}

From source file:com.kegare.caveworld.network.BuffMessage.java

License:Minecraft Mod Public

@Override
public void fromBytes(ByteBuf buffer) {
    int id = buffer.readInt();
    int duration = buffer.readInt();
    int amplifier = buffer.readInt();

    effect = new PotionEffect(id, duration, amplifier);
}

From source file:com.kegare.caveworld.network.CaveAchievementMessage.java

License:Minecraft Mod Public

@Override
public void fromBytes(ByteBuf buffer) {
    index = buffer.readInt();
}

From source file:com.kegare.caveworld.network.DimSyncMessage.java

License:Minecraft Mod Public

@Override
public void fromBytes(ByteBuf buffer) {
    dimensionId = buffer.readInt();
    data = ByteBufUtils.readTag(buffer);
}

From source file:com.kegare.frozenland.core.Config.java

License:Minecraft Mod Public

@Override
public void fromBytes(ByteBuf buf) {
    dimensionFrozenland = buf.readInt();
    biomeFrozenland = buf.readInt();/*w  ww  .  ja v a2s.  co m*/
    generateCaves = buf.readBoolean();
    generateRavine = buf.readBoolean();
    generateMineshaft = buf.readBoolean();
    generateVillage = buf.readBoolean();
    generateDungeons = buf.readBoolean();
}

From source file:com.kixeye.kixmpp.p2p.serialization.ProtostuffDecoder.java

License:Apache License

/**
 * Expose deserializer for unit testing.
 *
 * @param registry//from   w  ww.j  a  va 2 s.  co  m
 * @param buf
 * @return
 * @throws IOException
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Object deserializeFromByteBuf(MessageRegistry registry, ByteBuf buf) throws IOException {
    // get message class
    int typeIdx = buf.readInt();
    Class<?> clazz = registry.getClassFromId(typeIdx);

    // decode rest of array into object
    Schema schema = RuntimeSchema.getSchema(clazz);
    Object obj = schema.newMessage();
    ProtostuffIOUtil.mergeFrom(new ByteBufInputStream(buf), obj, schema);

    return obj;
}

From source file:com.ldp.nettydemo.netty.codec.NettyMessageDecoder.java

License:Apache License

@Override
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
    ByteBuf frame = (ByteBuf) super.decode(ctx, in);
    if (frame == null) {
        return null;
    }//  www. j  a  v a 2 s .  c o  m

    NettyMessage message = new NettyMessage();
    Header header = new Header();
    header.setCrcCode(frame.readInt());
    header.setLength(frame.readInt());
    header.setSessionID(frame.readLong());
    header.setType(frame.readByte());
    header.setPriority(frame.readByte());

    int size = frame.readInt();
    if (size > 0) {
        Map<String, Object> attch = new HashMap<String, Object>(size);
        int keySize = 0;
        byte[] keyArray = null;
        String key = null;
        for (int i = 0; i < size; i++) {
            keySize = frame.readInt();
            keyArray = new byte[keySize];
            frame.readBytes(keyArray);
            key = new String(keyArray, "UTF-8");
            attch.put(key, ByteObjConverter.ByteToObject(new ByteBufToBytes().read(frame)));
            //      attch.put(key, marshallingDecoder.decode(frame));
        }
        keyArray = null;
        key = null;
        header.setAttachment(attch);
    }
    if (frame.readableBytes() > 4) {
        message.setBody(ByteObjConverter.ByteToObject(new ByteBufToBytes().read(frame)));
        //       message.setBody(marshallingDecoder.decode(frame));
    }
    message.setHeader(header);
    return message;
}

From source file:com.linecorp.armeria.internal.grpc.ArmeriaMessageDeframer.java

License:Apache License

/**
 * Processes the gRPC compression header which is composed of the compression flag and the outer
 * frame length./*from w  ww.jav a  2s  . co m*/
 */
private void readHeader() {
    final ByteBuf buf = readableBuf();
    final int type = buf.readUnsignedByte();
    if ((type & RESERVED_MASK) != 0) {
        throw Status.INTERNAL.withDescription(DEBUG_STRING + ": Frame header malformed: reserved bits not zero")
                .asRuntimeException();
    }
    compressedFlag = (type & COMPRESSED_FLAG_MASK) != 0;

    // Update the required length to include the length of the frame.
    requiredLength = buf.readInt();
    if (requiredLength < 0 || requiredLength > maxMessageSizeBytes) {
        throw Status.RESOURCE_EXHAUSTED.withDescription(String.format("%s: Frame size %d exceeds maximum: %d. ",
                DEBUG_STRING, requiredLength, maxMessageSizeBytes)).asRuntimeException();
    }

    // Continue reading the frame body.
    state = State.BODY;
}

From source file:com.lothrazar.cyclicmagic.gui.container.PacketGuiShortOverride.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    fieldId = buf.readInt();
    value = buf.readInt();
}