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:com.seventh_root.ld33.common.network.packet.clientbound.UnitPurchaseClientBoundPacket.java

License:Apache License

@Override
public void write(ByteBuf buf) throws UnsupportedEncodingException {
    super.write(buf);
    writeString(buf, getPlayerUUID().toString());
    buf.writeInt(getX());
    buf.writeInt(getY());//from ww  w. ja  v  a  2s . co  m
    writeString(buf, getUnitType());
}

From source file:com.seventh_root.ld33.common.network.packet.clientbound.UnitSpawnClientBoundPacket.java

License:Apache License

@Override
public void write(ByteBuf buf) throws UnsupportedEncodingException {
    super.write(buf);
    writeString(buf, unitUUID);//  www. j  a  v  a 2 s . c  o  m
    writeString(buf, playerUUID);
    buf.writeInt(x);
    buf.writeInt(y);
    writeString(buf, type);
    buf.writeLong(completionTime);
}

From source file:com.seventh_root.ld33.common.network.packet.clientbound.WorldInformationClientBoundPacket.java

License:Apache License

@Override
public void write(ByteBuf buf) throws UnsupportedEncodingException {
    super.write(buf);
    buf.writeInt(getWidth());
    buf.writeInt(getHeight());//  ww  w. ja  v a 2 s  .c o  m
}

From source file:com.seventh_root.ld33.common.network.packet.Packet.java

License:Apache License

public void write(ByteBuf buf) throws UnsupportedEncodingException {
    buf.writeInt(getId());
}

From source file:com.seventh_root.ld33.common.network.packet.serverbound.PlayerLoginServerBoundPacket.java

License:Apache License

@Override
public void write(ByteBuf buf) throws UnsupportedEncodingException {
    super.write(buf);
    writeString(buf, getPlayerName());/*from   www . ja v a  2s  . c  om*/
    buf.writeInt(getEncryptedPassword().length);
    buf.writeBytes(getEncryptedPassword());
    buf.writeBoolean(isSignUp());
}

From source file:com.seventh_root.ld33.common.network.packet.serverbound.UnitMoveServerBoundPacket.java

License:Apache License

@Override
public void write(ByteBuf buf) throws UnsupportedEncodingException {
    super.write(buf);
    writeString(buf, getUnitUUID().toString());
    buf.writeInt(getTargetX());
    buf.writeInt(getTargetY());//  w  ww.  j a va  2 s  .  c  o m
}

From source file:com.seventh_root.ld33.common.network.packet.serverbound.UnitPurchaseServerBoundPacket.java

License:Apache License

@Override
public void write(ByteBuf buf) throws UnsupportedEncodingException {
    super.write(buf);
    buf.writeInt(getX());
    buf.writeInt(getY());//from w w w  . ja va  2  s . c o m
    writeString(buf, getUnitType());
}

From source file:com.sheldon.javaPrj.netty.TimeServerHandler.java

@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
    final ByteBuf time = ctx.alloc().buffer(4);
    time.writeInt((int) (System.currentTimeMillis() / 1000L + 2208988800L));

    final ChannelFuture f = ctx.writeAndFlush(time); // (3)
    f.addListener(new ChannelFutureListener() {
        @Override/*from  w  w  w .java  2 s .com*/
        public void operationComplete(ChannelFuture future) {
            assert f == future;
            ctx.close();
        }
    }); // (4)
}

From source file:com.smithsmodding.smithscore.common.player.event.PlayersConnectedUpdatedEvent.java

/**
 * Function used by the instance on the sending side to write its state top the Buffer before it is send to the
 * retrieving side.//from   www . j  a  va2  s  .c  om
 *
 * @param pMessageBuffer The buffer from the IMessage
 */
@Override
public void writeToMessageBuffer(ByteBuf pMessageBuffer) {
    pMessageBuffer.writeInt(commonSidedJoinedMap.size());

    for (UUID id : commonSidedJoinedMap.keySet()) {
        NetworkHelper.writeUUID(pMessageBuffer, id);
        ByteBufUtils.writeUTF8String(pMessageBuffer, commonSidedJoinedMap.get(id));
    }
}

From source file:com.smithsmodding.smithscore.common.player.event.PlayersOnlineUpdatedEvent.java

/**
 * Function used by the instance on the sending side to write its state top the Buffer before it is send to the
 * retrieving side./*from  ww  w.j  a  v  a2  s.  c o m*/
 *
 * @param pMessageBuffer The buffer from the IMessage
 */
@Override
public void writeToMessageBuffer(ByteBuf pMessageBuffer) {
    pMessageBuffer.writeInt(commonSidedOnlineMap.size());

    for (UUID id : commonSidedOnlineMap) {
        NetworkHelper.writeUUID(pMessageBuffer, id);
    }
}