List of usage examples for io.netty.buffer ByteBuf readDouble
public abstract double readDouble();
From source file:com.noahkurrack.onenine.network.MessageSingleParticleEvent.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { int particleNameLength = buf.readInt(); this.particleName = new String(buf.readBytes(particleNameLength).array()); this.xCoord = buf.readDouble(); this.yCoord = buf.readDouble(); this.zCoord = buf.readDouble(); this.xVelocity = buf.readDouble(); this.yVelocity = buf.readDouble(); this.zVelocity = buf.readDouble(); }
From source file:com.spotify.heroic.consumer.collectd.CollectdParser.java
License:Apache License
public static List<CollectdValue> parseValues(final ByteBuf frame, final int size) { final int n = frame.readUnsignedShort(); final List<Integer> types = ImmutableList.copyOf(IntStream.range(0, n).map(i -> { return frame.readByte(); }).iterator());//from w ww. j a va 2 s.c o m final ImmutableList.Builder<CollectdValue> values = ImmutableList.builder(); for (final int type : types) { switch (type) { case CollectdSample.COUNTER: final long c = frame.readLong(); if (c < 0) { throw new IllegalArgumentException("value too large for signed type"); } values.add(new Counter(c)); break; case CollectdSample.GAUGE: frame.order(ByteOrder.LITTLE_ENDIAN); values.add(new CollectdValue.Gauge(frame.readDouble())); frame.order(ByteOrder.BIG_ENDIAN); break; case CollectdSample.DERIVE: values.add(new CollectdValue.Derive(frame.readLong())); break; case CollectdSample.ABSOLUTE: final long a = frame.readLong(); if (a < 0) { throw new IllegalArgumentException("value too large for signed type"); } values.add(new CollectdValue.Absolute(a)); break; default: throw new IllegalArgumentException("invalid sample type: " + type); } } return values.build(); }
From source file:com.srotya.sidewinder.core.ingress.binary.SeriesDataPointDecoder.java
License:Apache License
public static DataPoint decodeBufToDPoint(ByteBuf buf) { int dbNameLength = buf.readInt(); if (dbNameLength < 0) { return null; }/*w w w . j av a 2 s . com*/ byte[] dbBytes = new byte[dbNameLength]; buf.readBytes(dbBytes); String dbName = new String(dbBytes); int measurementNameLength = buf.readInt(); if (measurementNameLength < 0) { return null; } byte[] measurementNameBytes = new byte[measurementNameLength]; buf.readBytes(measurementNameBytes); String measurementName = new String(measurementNameBytes); int valueNameLength = buf.readInt(); if (valueNameLength < 0) { return null; } byte[] valueNameBytes = new byte[valueNameLength]; buf.readBytes(valueNameBytes); String valueFieldName = new String(valueNameBytes); long timestamp = buf.readLong(); byte flag = buf.readByte(); DataPoint dp; if (flag == '0') { double value = buf.readDouble(); dp = new DataPoint(dbName, measurementName, valueFieldName, null, timestamp, value); dp.setFp(true); } else { long value = buf.readLong(); dp = new DataPoint(dbName, measurementName, valueFieldName, null, timestamp, value); } return dp; }
From source file:com.teambr.bookshelf.network.SyncableFieldPacket.java
License:Creative Commons License
/******************************************************************************************************************* * IMessage * *******************************************************************************************************************/ @Override/*from w w w. ja va2 s. c om*/ public void fromBytes(ByteBuf buf) { returnValue = buf.readBoolean(); id = buf.readInt(); value = buf.readDouble(); blockPosition = BlockPos.fromLong(buf.readLong()); }
From source file:com.theoriginalbit.moarperipherals.common.network.message.MessageGeneric.java
License:Apache License
@Override public void fromBytes(ByteBuf buf) { int nStr = buf.readInt(); stringData = new String[nStr]; if (nStr > 0) { for (int i = 0; i < nStr; ++i) { stringData[i] = ByteBufUtils.readUTF8String(buf); }//from w w w.ja va2s . c o m } int nInt = buf.readInt(); intData = new int[nInt]; if (nInt > 0) { for (int i = 0; i < nInt; ++i) { intData[i] = buf.readInt(); } } int nByte = buf.readInt(); byteData = new byte[nByte]; if (nByte > 0) { buf.readBytes(byteData); } int nChar = buf.readInt(); charData = new char[nChar]; if (nChar > 0) { for (int i = 0; i < nChar; ++i) { charData[i] = buf.readChar(); } } int nFloat = buf.readInt(); floatData = new float[nFloat]; if (nFloat > 0) { for (int i = 0; i < nFloat; ++i) { floatData[i] = buf.readFloat(); } } int nDouble = buf.readInt(); doubleData = new double[nDouble]; if (nDouble > 0) { for (int i = 0; i < nDouble; ++i) { doubleData[i] = buf.readDouble(); } } boolean wasNBT = buf.readBoolean(); if (wasNBT) { nbtData = ByteBufUtils.readTag(buf); } }
From source file:com.torodb.mongowp.bson.netty.DefaultNettyBsonLowLevelReader.java
License:Apache License
@Override BsonDecimal128 readDecimal128(@Loose @ModifiesIndexes ByteBuf byteBuf) { return LongsBsonDecimal128.newInstance(new BigDecimal(byteBuf.readDouble())); }
From source file:com.yyon.grapplinghook.network.GrappleAttachMessage.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.id = buf.readInt(); this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.controlid = buf.readInt(); this.entityid = buf.readInt(); this.maxlen = buf.readInt(); int blockx = buf.readInt(); int blocky = buf.readInt(); int blockz = buf.readInt(); this.blockpos = new BlockPos(blockx, blocky, blockz); }
From source file:com.yyon.grapplinghook.network.GrappleAttachPosMessage.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.id = buf.readInt(); this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); }
From source file:com.yyon.grapplinghook.network.PlayerMovementMessage.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { try {//from w w w.j a v a 2s .c o m this.entityId = buf.readInt(); this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.mx = buf.readDouble(); this.my = buf.readDouble(); this.mz = buf.readDouble(); } catch (Exception e) { System.out.println(buf); } }
From source file:daxum.temporalconvergence.network.PacketDodgeSuccess.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { long uuidMost = buf.readLong(); long uuidLeast = buf.readLong(); mainPlayerUUID = new UUID(uuidMost, uuidLeast); ox = buf.readDouble(); oy = buf.readDouble();/*from w w w. j a va2s .c o m*/ oz = buf.readDouble(); }