List of usage examples for io.netty.buffer ByteBuf writeShort
public abstract ByteBuf writeShort(int value);
From source file:it.jnrpe.net.JNRPEResponseEncoder.java
License:Apache License
/** * Method encode./*from ww w . j av a 2 s .c om*/ * @param ctx ChannelHandlerContext * @param msg JNRPEResponse * @param out ByteBuf * @throws Exception */ @Override protected final void encode(final ChannelHandlerContext ctx, final JNRPEResponse msg, final ByteBuf out) throws Exception { msg.updateCRC(); out.writeShort(msg.getPacketVersion().intValue()); out.writeShort(msg.getPacketType().intValue()); out.writeInt(msg.getCRC()); out.writeShort(msg.getResultCode()); out.writeBytes(msg.getBuffer()); out.writeBytes(msg.getDummy()); }
From source file:ivorius.ivtoolkit.network.IvPacketHelper.java
License:Apache License
public static void writeNumber(ByteBuf buffer, Number number) { if (number instanceof Byte) { buffer.writeByte((Byte) number); } else if (number instanceof Double) { buffer.writeDouble((Double) number); } else if (number instanceof Float) { buffer.writeFloat((Float) number); } else if (number instanceof Integer) { buffer.writeInt((Integer) number); } else if (number instanceof Long) { buffer.writeLong((Long) number); } else if (number instanceof Short) { buffer.writeShort((Short) number); } else {/* ww w . ja v a 2s . c o m*/ throw new IllegalArgumentException(); } }
From source file:mal.carbonization.network.FluidTransportMessageServer.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { buf.writeInt(xpos);//from w w w.ja va 2 s .c om buf.writeInt(ypos); buf.writeInt(zpos); FluidStack stack = tank.getFluid(); if (stack != null && stack.getFluid() != null) { buf.writeShort(stack.getFluid().getID()); buf.writeInt(stack.amount); } else buf.writeShort(-1); buf.writeInt(tank.getCapacity()); buf.writeInt(maxcooldown); buf.writeInt(cooldown); buf.writeInt(transferAmount); buf.writeInt(sidestates.length); for (int i = 0; i < sidestates.length; i++) { buf.writeByte(sidestates[i]); } //System.out.println(sidestates[0]); }
From source file:matteroverdrive.api.weapon.WeaponShot.java
License:Open Source License
public void writeTo(ByteBuf buf) { buf.writeInt(seed);//from www . j a v a 2 s . c o m buf.writeFloat(damage); buf.writeFloat(accuracy); buf.writeInt(color); buf.writeShort(range); buf.writeByte(count); }
From source file:matteroverdrive.network.packet.server.PacketMatterScannerUpdate.java
License:Open Source License
@Override public void toBytes(ByteBuf buf) { selected.writeToBuffer(buf);/* w w w. j a v a 2 s. co m*/ buf.writeShort(this.page); //buffer.writeBoolean(this.panelOpen); buf.writeShort(slot); }
From source file:me.ferrybig.p2pnetwork.codec.packets.PeerExchangePacket.java
@Override public void write(ByteBuf buf) { buf.writeByte(addresses.size());/*w w w. ja v a 2 s.c om*/ for (Map.Entry<SocketAddress, Byte> entry : addresses.entrySet()) { if (entry.getKey() instanceof InetSocketAddress) { InetSocketAddress inetSocketAddress = (InetSocketAddress) entry.getKey(); buf.writeByte(1); // Inet address byte[] address = inetSocketAddress.getAddress().getAddress(); buf.writeInt(address.length); buf.writeBytes(address); buf.writeShort(inetSocketAddress.getPort()); } else { buf.writeByte(0); // Unknown address } buf.writeByte(entry.getValue()); } }
From source file:me.ferrybig.p2pnetwork.codec.packets.PingPacket.java
@Override public void write(ByteBuf buf) { buf.writeShort(data.length); buf.writeBytes(data); }
From source file:me.melchor9000.net.resolver.DNSMessage.java
License:Open Source License
@Override public void toByteBuf(@NotNull ByteBuf buffer) { int flags = 0; if (queryOrResponse) flags |= 0x8000;/*from w w w.j a v a 2 s. c o m*/ flags |= (opcode << 11) & 0x7800; if (authoritativeResponse) flags |= 0x0400; if (truncated) flags |= 0x0200; if (recursionDesired) flags |= 0x0100; if (recursionAvailable) flags |= 0x0080; flags |= responseCode & 0xF; buffer.writeShort(id); buffer.writeShort(flags); buffer.writeShort(questionRecords.size()); buffer.writeShort(answerRecords.size()); buffer.writeShort(authorityRecords.size()); buffer.writeShort(additionalRecords.size()); for (DNSQuery query : questionRecords) query.toByteBuf(buffer); for (DNSResourceRecord record : answerRecords) record.toByteBuf(buffer); for (DNSResourceRecord record : authorityRecords) record.toByteBuf(buffer); for (DNSResourceRecord record : additionalRecords) record.toByteBuf(buffer); }
From source file:me.melchor9000.net.resolver.DNSMX.java
License:Open Source License
@Override public void toByteBuf(@NotNull ByteBuf buffer) { buffer.writeShort(preference); writeName(buffer, exchange); }
From source file:me.melchor9000.net.resolver.DNSQuery.java
License:Open Source License
@Override public void toByteBuf(@NotNull ByteBuf buffer) { writeName(buffer, name); buffer.writeShort(type); buffer.writeShort(mclass); }