List of usage examples for io.netty.buffer ByteBuf writeInt
public abstract ByteBuf writeInt(int value);
From source file:cn.academy.core.ctrl.SkillStateMessage.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(action.ordinal()); buf.writeInt(stateID);// w ww . j a v a 2 s . c o m ByteBufUtils.writeUTF8String(buf, playerName); ByteBufUtils.writeUTF8String(buf, className); ByteBufUtils.writeTag(buf, nbt); }
From source file:cn.academy.energy.msg.fr.MsgFRAction.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(x).writeInt(y).writeInt(z); if (type == ActionType.REG) { buf.writeBoolean(true);//from w w w. j a va2 s . co m buf.writeInt(coords[0]).writeInt(coords[1]).writeInt(coords[2]); ByteBufUtils.writeUTF8String(buf, pwd); } else { buf.writeBoolean(false); } }
From source file:cn.academy.energy.msg.fr.MsgFRInit.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { if (curChannel == null) curChannel = ""; ByteBufUtils.writeUTF8String(buf, curChannel); buf.writeInt(cnMap.size()); for (Entry<String, int[]> ent : cnMap.entrySet()) { ByteBufUtils.writeUTF8String(buf, ent.getKey()); int[] arr = ent.getValue(); for (int i = 0; i < 3; ++i) { buf.writeInt(arr[i]);//www .j a v a 2 s . c o m } } }
From source file:cn.academy.energy.msg.matrix.MsgInitMatrix.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(x).writeInt(y).writeInt(z); ByteBufUtils.writeUTF8String(buf, channel); ByteBufUtils.writeUTF8String(buf, pwd); }
From source file:cn.academy.energy.msg.MsgEnergyHeartbeat.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(x).writeInt(y).writeInt(z).writeFloat(energy).writeBoolean(loaded); }
From source file:cn.academy.energy.msg.node.MsgInitNode.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(x).writeInt(y).writeInt(z); ByteBufUtils.writeUTF8String(buf, ssid); ByteBufUtils.writeUTF8String(buf, pwd); }
From source file:cn.lambdacraft.mob.network.MsgSentrySync.java
License:Open Source License
@Override public void toBytes(ByteBuf outputStream) { outputStream.writeInt(xCoord); outputStream.writeInt(yCoord);/*from w w w . j a va 2 s . co m*/ outputStream.writeInt(zCoord); outputStream.writeBoolean(isValid); if (isValid) { outputStream.writeInt(linkX); outputStream.writeInt(linkY); outputStream.writeInt(linkZ); } }
From source file:cn.lambdalib.multiblock.MsgBlockMulti.java
License:MIT License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(x).writeInt(y).writeInt(z).writeByte(dir.ordinal()).writeByte(s); }
From source file:cn.liutils.api.player.state.StateBase.java
License:Open Source License
public final void toBytes(ByteBuf buf) { buf.writeInt(tick); writeBytes(buf); }
From source file:cn.songm.songmq.broker.serialize.KryoCodecUtil.java
License:Apache License
public void encode(final ByteBuf out, final Object message) throws IOException { ByteArrayOutputStream byteArrayOutputStream = null; try {/*from w ww .j a v a 2 s .c o m*/ byteArrayOutputStream = new ByteArrayOutputStream(); KryoSerialize kryoSerialization = new KryoSerialize(pool); kryoSerialization.serialize(byteArrayOutputStream, message); byte[] body = byteArrayOutputStream.toByteArray(); int dataLength = body.length; out.writeInt(dataLength); out.writeBytes(body); } finally { byteArrayOutputStream.close(); } }