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:allout58.mods.techtree.network.message.ChangeNodeMode.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    uuid = ByteBufUtils.readUTF8String(buf);
    nodeID = buf.readInt();
    newMode = NodeMode.valueOf(ByteBufUtils.readUTF8String(buf));
}

From source file:allout58.mods.techtree.network.message.RequestMode.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.clientID = ByteBufUtils.readUTF8String(buf);
    this.nodeID = buf.readInt();
}

From source file:allout58.mods.techtree.network.message.SendResearch.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    nodeID = buf.readInt();
    research = buf.readInt();
    uuid = ByteBufUtils.readUTF8String(buf);
}

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

License:Apache License

/**
 * Decodes the message from a buffer. This method increments the refcount of the bytebuf passed
 * by 1.//from  w  ww.  j  a  va  2 s  .  c om
 *
 * @param in the buffer
 * @param prototype a message prototype used to infer the type of the message
 * @return the message decoded
 */
public static RPCProtoMessage decode(ByteBuf in, ProtoMessage.Type prototype) {
    int length = in.readInt();
    byte[] serialized = new byte[length];
    in.readBytes(serialized);
    in.retain();
    return new RPCProtoMessage(serialized, prototype, new DataNettyBufferV2(in));
}

From source file:appeng.core.sync.network.AppEngClientPacketHandler.java

License:Open Source License

@Override
public void onPacketData(final INetworkInfo manager, final INetHandler handler, final FMLProxyPacket packet,
        final EntityPlayer player) {
    final ByteBuf stream = packet.payload();

    try {//ww  w  .  j a  va  2 s . c o m
        final int packetType = stream.readInt();
        final AppEngPacket pack = PacketTypes.getPacket(packetType).parsePacket(stream);

        final PacketCallState callState = new PacketCallState() {

            @Override
            public void call(final AppEngPacket appEngPacket) {
                appEngPacket.clientPacketData(manager, appEngPacket, Minecraft.getMinecraft().thePlayer);
            }
        };

        pack.setCallParam(callState);
        PacketThreadUtil.checkThreadAndEnqueue(pack, handler, Minecraft.getMinecraft());
        callState.call(pack);
    } catch (final InstantiationException e) {
        AELog.debug(e);
    } catch (final IllegalAccessException e) {
        AELog.debug(e);
    } catch (final IllegalArgumentException e) {
        AELog.debug(e);
    } catch (final InvocationTargetException e) {
        AELog.debug(e);
    }
}

From source file:appeng.core.sync.network.AppEngServerPacketHandler.java

License:Open Source License

@Override
public void onPacketData(final INetworkInfo manager, final INetHandler handler, final FMLProxyPacket packet,
        final EntityPlayer player) {
    final ByteBuf stream = packet.payload();

    try {//from  ww w  .  j a  v  a 2 s. c  o  m
        final int packetType = stream.readInt();
        final AppEngPacket pack = PacketTypes.getPacket(packetType).parsePacket(stream);

        final PacketCallState callState = new PacketCallState() {

            @Override
            public void call(final AppEngPacket appEngPacket) {
                appEngPacket.serverPacketData(manager, appEngPacket, player);
            }
        };

        pack.setCallParam(callState);
        PacketThreadUtil.checkThreadAndEnqueue(pack, handler, ((EntityPlayerMP) player).getServer());
        callState.call(pack);
    } catch (final InstantiationException e) {
        AELog.debug(e);
    } catch (final IllegalAccessException e) {
        AELog.debug(e);
    } catch (final IllegalArgumentException e) {
        AELog.debug(e);
    } catch (final InvocationTargetException e) {
        AELog.debug(e);
    }
}

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

License:Open Source License

public PacketAssemblerAnimation(final ByteBuf stream) throws IOException {
    this.x = stream.readInt();
    this.y = stream.readInt();
    this.z = stream.readInt();
    this.rate = stream.readByte();
    this.is = AEItemStack.loadItemStackFromPacket(stream);
}

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

License:Open Source License

public PacketClick(final ByteBuf stream) {
    this.x = stream.readInt();
    this.y = stream.readInt();
    this.z = stream.readInt();
    byte side = stream.readByte();
    if (side != -1) {
        this.side = EnumFacing.values()[side];
    } else {/* w w w  . ja  va2  s  .c  o m*/
        this.side = null;
    }
    this.hitX = stream.readFloat();
    this.hitY = stream.readFloat();
    this.hitZ = stream.readFloat();
    this.hand = EnumHand.values()[stream.readByte()];
}

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

License:Open Source License

public PacketCompassRequest(final ByteBuf stream) {
    this.attunement = stream.readLong();
    this.cx = stream.readInt();
    this.cz = stream.readInt();
    this.cdy = stream.readInt();
}

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

License:Open Source License

public PacketCompassResponse(final ByteBuf stream) {
    this.attunement = stream.readLong();
    this.cx = stream.readInt();
    this.cz = stream.readInt();
    this.cdy = stream.readInt();

    this.cr = new CompassResult(stream.readBoolean(), stream.readBoolean(), stream.readDouble());
}