List of usage examples for io.netty.buffer ByteBuf writeLong
public abstract ByteBuf writeLong(long value);
From source file:com.smithsmodding.smithscore.client.events.gui.ContainerGuiClosedEvent.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 w w w . j av a2 s . c o m * * @param pMessageBuffer The buffer from the IMessage */ @Override public void writeToMessageBuffer(ByteBuf pMessageBuffer) { pMessageBuffer.writeLong(playerID.getMostSignificantBits()); pMessageBuffer.writeLong(playerID.getLeastSignificantBits()); ByteBufUtils.writeUTF8String(pMessageBuffer, containerID); }
From source file:com.smithsmodding.smithscore.util.common.NetworkHelper.java
/** * Method to easily write UUIDs to a MessageBuffer. * * @param buffer The buffer to write to. * @param id The UUID to write./*from w ww .ja va 2 s.c o m*/ */ public static void writeUUID(ByteBuf buffer, UUID id) { buffer.writeLong(id.getMostSignificantBits()); buffer.writeLong(id.getLeastSignificantBits()); }
From source file:com.spotify.folsom.client.binary.BinaryMemcacheDecoderTest.java
License:Apache License
@Test public void test() throws Exception { GetRequest request = new GetRequest(KEY, OpCode.GET, 123, OPAQUE); BinaryMemcacheDecoder decoder = new BinaryMemcacheDecoder(); ByteBuf cb = Unpooled.buffer(30); cb.writeByte(0x81);//w ww. j a v a 2s . c om cb.writeByte(OpCode.GET); cb.writeShort(3); cb.writeByte(0); cb.writeZero(1); cb.writeShort(0); cb.writeInt(6); cb.writeInt(request.getOpaque()); cb.writeLong(258); cb.writeBytes(KEY.getBytes()); cb.writeBytes(VALUE.getBytes()); List<Object> out = Lists.newArrayList(); decoder.decode(null, cb, out); @SuppressWarnings("unchecked") List<ResponsePacket> replies = (List<ResponsePacket>) out.get(0); request.handle(replies); GetResult<byte[]> getResult = request.get(); assertEquals(258, getResult.getCas()); assertEquals(VALUE, TRANSCODER.decode(getResult.getValue())); }
From source file:com.spotify.netty.handler.codec.zmtp.ZMTPUtils.java
License:Apache License
static void writeLong(final ByteBuf buffer, final long value) { if (buffer.order() == BIG_ENDIAN) { buffer.writeLong(value); } else {/*from w w w .j a va2 s . c om*/ buffer.writeLong(ByteBufUtil.swapLong(value)); } }
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP10WireFormat.java
License:Apache License
/** * Write a ZMTP/1.0 frame length.// ww w .j a v a2s .com * * @param out Target buffer. * @param maxLength The maximum length of the field. * @param length The length. */ static void writeLength(final ByteBuf out, final long maxLength, final long length) { if (maxLength < 255) { out.writeByte((byte) length); } else { out.writeByte(0xFF); out.writeLong(length); } }
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP20WireFormat.java
License:Apache License
/** * Write a ZMTP/2.0 greeting signature.//from w w w . ja va 2s . c o m * * @param out The buffer to write the signature to. */ static void writeSignature(final ByteBuf out) { out.writeByte(0xff); out.writeLong(0x00); out.writeByte(0x7f); }
From source file:com.spotify.netty4.handler.codec.zmtp.ZMTP20WireFormat.java
License:Apache License
/** * Write a backwards compatible ZMTP/2.0 greeting signature. * * @param out The buffer to write the signature to. * @param identity The socket identity./* ww w . j av a 2 s .co m*/ */ static void writeCompatSignature(final ByteBuf out, final ByteBuffer identity) { out.writeByte(0xFF); out.writeLong(identity.remaining() + 1); out.writeByte(0x7f); }
From source file:com.srotya.sidewinder.core.ingress.binary.SeriesDataPointEncoder.java
License:Apache License
public static void encodeDPointToBuf(ByteBuf buf, DataPoint dataPoint) { byte[] dbNameBytes = dataPoint.getDbName().getBytes(); buf.writeInt(dbNameBytes.length);// w ww .j a va 2s . co m buf.writeBytes(dbNameBytes); byte[] measurementNameBytes = dataPoint.getMeasurementName().getBytes(); buf.writeInt(measurementNameBytes.length); buf.writeBytes(measurementNameBytes); byte[] valueNameBytes = dataPoint.getValueFieldName().getBytes(); buf.writeInt(valueNameBytes.length); buf.writeBytes(valueNameBytes); buf.writeLong(dataPoint.getTimestamp()); if (dataPoint.isFp()) { buf.writeByte('0'); buf.writeDouble(dataPoint.getValue()); } else { buf.writeByte('1'); buf.writeLong(dataPoint.getLongValue()); } }
From source file:com.teambr.bookshelf.network.ClientOverridePacket.java
License:Creative Commons License
@Override public void toBytes(ByteBuf buf) { buf.writeLong(blockPosition.toLong()); new PacketBuffer(buf).writeCompoundTag(tag); }
From source file:com.teambr.bookshelf.network.SyncableFieldPacket.java
License:Creative Commons License
@Override public void toBytes(ByteBuf buf) { buf.writeBoolean(returnValue);//from w w w . j ava 2 s .c om buf.writeInt(id); buf.writeDouble(value); buf.writeLong(blockPosition.toLong()); }