List of usage examples for io.netty.buffer ByteBuf readInt
public abstract int readInt();
From source file:com.srotya.sidewinder.core.ingress.binary.SeriesDataPointDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext arg0, ByteBuf buf, List<Object> output) throws Exception { int dpCount = buf.readInt(); for (int i = 0; i < dpCount; i++) { DataPoint d = decodeBufToDPoint(buf); if (d == null) { System.out.println("Bad data point"); return; } else {/*from w w w . j a va 2s.c o m*/ output.add(d); } } }
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; }//from ww w . j a v a2 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 ww.ja v a 2 s .c o m public void fromBytes(ByteBuf buf) { returnValue = buf.readBoolean(); id = buf.readInt(); value = buf.readDouble(); blockPosition = BlockPos.fromLong(buf.readLong()); }
From source file:com.teambr.modularsystems.core.network.DeleteValuesPacket.java
License:Creative Commons License
@Override public void fromBytes(ByteBuf buf) { this.blockID = buf.readInt(); this.meta = buf.readInt(); }
From source file:com.teambr.modularsystems.core.network.SyncBlockValues.java
License:Creative Commons License
@Override public void fromBytes(ByteBuf buf) { byte[] compressedBytes = null; int readableBytes = buf.readInt(); if (readableBytes > 0) compressedBytes = buf.readBytes(readableBytes).array(); if (compressedBytes != null) this.jsonBlockValues = CompressionFunctions.decompressStringFromByteArray(compressedBytes); }
From source file:com.teambr.modularsystems.storage.network.StorageMessage.java
License:Creative Commons License
@Override public void fromBytes(ByteBuf buf) { message = MESSAGE_ACTION.values()[buf.readInt()]; }
From source file:com.teambrmodding.neotech.network.OpenContainerGuiPacket.java
License:Creative Commons License
/******************************************************************************************************************* * IMessage * *******************************************************************************************************************/ @Override//from w ww . ja v a 2 s . c om public void fromBytes(ByteBuf buf) { blockPos = BlockPos.fromLong(buf.readLong()); id = buf.readInt(); }
From source file:com.tesora.dve.db.mysql.libmy.MyFieldPktResponse.java
License:Open Source License
private void unpackTypeInfo(ByteBuf cb) { int remainingPayload = cb.readableBytes(); int charsetOffset = remainingPayload + CHARSET_OFFSET_RELATIVE_TO_EOF; cb.skipBytes(charsetOffset);//from www. ja v a 2 s. c o m charset = cb.readByte(); cb.skipBytes(1); column_length = cb.readInt();//TODO: this should be an unsigned int. Will cause problems if length exceeds Integer.MAX_VALUE. column_type = MyFieldType.fromByte(cb.readByte()); flags = cb.readShort(); scale = cb.readByte(); //plus two pad bytes of zero }
From source file:com.tesora.dve.db.mysql.libmy.MyHandshakeV10.java
License:Open Source License
@Override public void unmarshallMessage(ByteBuf cb) { protocolVersion = cb.readByte();// w w w. ja va 2s.c o m serverVersion = cb.readSlice(cb.bytesBefore((byte) 0)).toString(CharsetUtil.UTF_8); cb.skipBytes(1); // skip the NULL terminator threadID = cb.readInt(); scrambleBuffer1st = MysqlAPIUtils.readBytesAsString(cb, 8, CharsetUtil.ISO_8859_1); cb.skipBytes(1); long sc1 = cb.readUnsignedShort(); serverCharset = cb.readByte(); serverStatus = cb.readShort(); long sc2 = Long.rotateLeft(cb.readUnsignedShort(), 16); setServerCapabilities(sc1 + sc2); scrambleBufferSize = new Integer(cb.readByte()); cb.skipBytes(10); //unused bytes scrambleBuffer2nd = cb.readSlice(cb.bytesBefore((byte) 0)).toString(CharsetUtil.ISO_8859_1); cb.skipBytes(1); if ((serverCapabilitiesasLong & ClientCapabilities.CLIENT_PLUGIN_AUTH) == ClientCapabilities.CLIENT_PLUGIN_AUTH) { plugInProvidedData = cb.readSlice(cb.bytesBefore((byte) 0)).toString(CharsetUtil.UTF_8); } }
From source file:com.tesora.dve.db.mysql.libmy.MyLoginRequest.java
License:Open Source License
@Override public void unmarshallMessage(ByteBuf cb) { clientCapabilities = cb.readUnsignedInt(); boolean hasConnectDatabase = ((clientCapabilities & ClientCapabilities.CLIENT_CONNECT_WITH_DB) == ClientCapabilities.CLIENT_CONNECT_WITH_DB); maxPacketSize = cb.readInt(); clientCharset = cb.readByte();/*from w w w . j a va 2s . c o m*/ cb.skipBytes(23); // login request has a 23 byte filler username = cb.readSlice(cb.bytesBefore((byte) 0)).toString(CharsetUtil.UTF_8); cb.skipBytes(1); // skip the NULL terminator byte passwordLength = cb.readByte(); byte[] passwordBytes = new byte[passwordLength]; cb.getBytes(cb.readerIndex(), passwordBytes, 0, passwordLength); password = new String(passwordBytes, CharsetUtil.ISO_8859_1); cb.skipBytes(passwordLength); // if the clientCapabilities flag has the CLIENT_CONNECT_WITH_DB bit set, // then this message contains an initial database to connect to if (hasConnectDatabase) { database = cb.readSlice(cb.bytesBefore((byte) 0)).toString(CharsetUtil.UTF_8); if (database.length() < 1) { database = null; } } }