List of usage examples for io.netty.buffer ByteBuf writeInt
public abstract ByteBuf writeInt(int value);
From source file:com.couchbase.client.core.message.kv.subdoc.multi.SubMultiMutationRequest.java
License:Apache License
private static ByteBuf encode(List<MutationCommand> commands) { //FIXME a way of using the pooled allocator? CompositeByteBuf compositeBuf = Unpooled.compositeBuffer(commands.size()); for (MutationCommand command : commands) { byte[] pathBytes = command.path().getBytes(CharsetUtil.UTF_8); short pathLength = (short) pathBytes.length; ByteBuf commandBuf = Unpooled.buffer(4 + pathLength + command.fragment().readableBytes()); commandBuf.writeByte(command.opCode()); if (command.createIntermediaryPath()) { commandBuf.writeByte(KeyValueHandler.SUBDOC_BITMASK_MKDIR_P); //0 | SUBDOC_BITMASK_MKDIR_P } else {// w ww . ja v a 2s. c om commandBuf.writeByte(0); } commandBuf.writeShort(pathLength); commandBuf.writeInt(command.fragment().readableBytes()); commandBuf.writeBytes(pathBytes); //copy the fragment but don't move indexes (in case it is retained and reused) commandBuf.writeBytes(command.fragment(), command.fragment().readerIndex(), command.fragment().readableBytes()); //eagerly release the fragment once it's been copied command.fragment().release(); //add the command to the composite buffer compositeBuf.addComponent(commandBuf); compositeBuf.writerIndex(compositeBuf.writerIndex() + commandBuf.readableBytes()); } return compositeBuf; }
From source file:com.crowsofwar.avatar.common.bending.earth.EarthbendingState.java
License:Open Source License
@Override public void writeBytes(ByteBuf buf) { buf.writeInt(pickupBlock == null ? -1 : pickupBlock.getID()); }
From source file:com.crowsofwar.avatar.common.bending.fire.FirebendingState.java
License:Open Source License
@Override public void writeBytes(ByteBuf buf) { buf.writeInt(getFireArcId()); }
From source file:com.crowsofwar.avatar.common.data.AbilityData.java
License:Open Source License
public void toBytes(ByteBuf buf) { buf.writeInt(ability.getId()); // ability ID read from createFromBytes buf.writeFloat(xp); }
From source file:com.crowsofwar.avatar.common.data.BendingState.java
License:Open Source License
public final void toBytes(ByteBuf buf) { buf.writeInt(progressionPoints); writeBytes(buf); }
From source file:com.crowsofwar.avatar.common.data.CachedEntity.java
License:Open Source License
public void toBytes(ByteBuf buf) { buf.writeInt(entityId); }
From source file:com.crowsofwar.avatar.common.entity.EntityWallSegment.java
License:Open Source License
@Override public void writeSpawnData(ByteBuf buf) { buf.writeFloat(height); buf.writeInt(offset); }
From source file:com.crowsofwar.avatar.common.network.PacketModularData.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(changed.size()); for (Networker.Property key : changed) { buf.writeInt(key.id());/*from w ww.j av a 2 s . c o m*/ transmitters.get(key).write(buf, currentData.get(key)); } }
From source file:com.crowsofwar.avatar.common.network.packets.PacketCParticles.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(particle.id()); buf.writeInt(minimum);//from w ww . ja va 2 s .c o m buf.writeInt(maximum); buf.writeDouble(x); buf.writeDouble(y); buf.writeDouble(z); buf.writeDouble(maxVelocityX); buf.writeDouble(maxVelocityY); buf.writeDouble(maxVelocityZ); }
From source file:com.crowsofwar.avatar.common.network.packets.PacketCRemoveStatusControl.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(control.id()); }