Example usage for io.netty.buffer ByteBuf writeInt

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

Introduction

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

Prototype

public abstract ByteBuf writeInt(int value);

Source Link

Document

Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.

Usage

From source file:UdpClient.java

License:Open Source License

public static void main(String args[]) {

    byte[] buf = new byte[256];
    DatagramSocket socket = null;
    try {/*from   w  w w. j a  va 2 s  .c  o m*/
        socket = new DatagramSocket();
    } catch (SocketException e) {
        e.printStackTrace();
    }
    InetAddress address = null;
    try {
        address = InetAddress.getLoopbackAddress();
        System.out.println(address);
    } catch (Exception e) {
        e.printStackTrace();
    }
    buf = "hello".getBytes();
    ByteBuf nett_buf = Unpooled.buffer();

    InetSocketAddress socketAddress = new InetSocketAddress(address, 5246);
    Scanner sc = new Scanner(System.in);
    {
        System.out.println("\nEnter Capwap Message ID");
        //int longIn = 4294967294;
        int longIn = 0XFFFFFFFE;
        nett_buf.writeInt(longIn);
        buf = nett_buf.array();

        DatagramPacket packet = new DatagramPacket(buf, nett_buf.writerIndex(), address, 5246);
        try {
            socket.send(packet);
            System.out.printf("\nSending Capwap Message %x ", longIn);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    ByteBufUtils.writeUTF8String(buf, uuid);
    buf.writeInt(nodeID);
    ByteBufUtils.writeUTF8String(buf, newMode.name());
}

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

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    ByteBufUtils.writeUTF8String(buf, clientID);
    buf.writeInt(nodeID);
}

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

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(nodeID);
    buf.writeInt(research);
    ByteBufUtils.writeUTF8String(buf, uuid);
}

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

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeInt(mMessageEncoded.length);
    out.writeBytes(mMessageEncoded);
}

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

License:Open Source License

public PacketAssemblerAnimation(final BlockPos pos, final byte rate, final IAEItemStack is) throws IOException {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(this.x = pos.getX());
    data.writeInt(this.y = pos.getY());
    data.writeInt(this.z = pos.getZ());
    data.writeByte(this.rate = rate);
    is.writeToPacket(data);/*from   w w w  . ja v  a 2s.  c  om*/
    this.is = is;

    this.configureWrite(data);
}

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

License:Open Source License

public PacketClick(final BlockPos pos, final EnumFacing side, final float hitX, final float hitY,
        final float hitZ, final EnumHand hand) {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(this.x = pos.getX());
    data.writeInt(this.y = pos.getY());
    data.writeInt(this.z = pos.getZ());
    if (side == null) {
        data.writeByte(-1);/*from  ww w . j a  v  a2  s .  c o m*/
    } else {
        data.writeByte(side.ordinal());
    }
    data.writeFloat(this.hitX = hitX);
    data.writeFloat(this.hitY = hitY);
    data.writeFloat(this.hitZ = hitZ);
    data.writeByte(hand.ordinal());

    this.configureWrite(data);
}

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

License:Open Source License

public PacketCompassRequest(final long attunement, final int cx, final int cz, final int cdy) {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeLong(this.attunement = attunement);
    data.writeInt(this.cx = cx);
    data.writeInt(this.cz = cz);
    data.writeInt(this.cdy = cdy);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketCompassResponse(final PacketCompassRequest req, final boolean hasResult, final boolean spin,
        final double radians) {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeLong(this.attunement = req.attunement);
    data.writeInt(this.cx = req.cx);
    data.writeInt(this.cz = req.cz);
    data.writeInt(this.cdy = req.cdy);

    data.writeBoolean(hasResult);/*  w  ww . j ava  2 s. co  m*/
    data.writeBoolean(spin);
    data.writeDouble(radians);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketConfigButton(final Settings option, final boolean rotationDirection) {
    this.option = option;
    this.rotationDirection = rotationDirection;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(option.ordinal());//  w  w w  .  j  a va2 s  . c  om
    data.writeBoolean(rotationDirection);

    this.configureWrite(data);
}