List of usage examples for io.netty.buffer ByteBuf readBoolean
public abstract boolean readBoolean();
From source file:org.starnub.starbounddata.types.variants.Variant.java
License:Open Source License
@Override public void read(ByteBuf in) { this.variantType = VariantType.values()[in.readUnsignedByte()]; switch (variantType) { case NIL: {//from w w w . ja v a 2s. co m value = null; break; } case DOUBLE: { value = in.readDouble(); break; } case BOOLEAN: { value = in.readBoolean(); break; } case INTEGER: { value = VLQ.readUnsignedFromBufferNoObject(in); break; } case STRING: { value = readVLQString(in); break; } case LIST: { value = new VariantList(in); break; } case MAP: value = new VariantMap(in); break; default: System.err.println("Unknown Variant Type, Variant Byte: " + variantType); } }
From source file:org.starnub.starbounddata.types.warp.ClientShipWorld.java
License:Open Source License
@Override public void read(ByteBuf in) { boolean hasUUID = in.readBoolean(); if (hasUUID) { this.uuid = readUUID(in); }//from w w w.j a v a 2 s .c o m }
From source file:org.starnub.starbounddata.types.warp.MissionWorld.java
License:Open Source License
@Override public void read(ByteBuf in) { this.name = readVLQString(in); boolean hasUUID = in.readBoolean(); if (hasUUID) { this.uuid = readUUID(in); }/* w ww . j a v a 2s . c o m*/ }
From source file:pneumaticCraft.common.network.PacketPlaySound.java
License:LGPL
@Override public void fromBytes(ByteBuf buffer) { super.fromBytes(buffer); sound = ByteBufUtils.readUTF8String(buffer); volume = buffer.readFloat();//from www. j a va 2s .c om pitch = buffer.readFloat(); bool = buffer.readBoolean(); }
From source file:portablejim.bbw.network.PacketWandActivate.java
License:Open Source License
@Override public void fromBytes(ByteBuf buffer) { keyActive = buffer.readBoolean(); }
From source file:se.sics.caracaldb.flow.FlowMessageSerializer.java
License:Open Source License
private Chunk chunkFromBinary(ByteBuf buf, MessageFields fields) { UUID flowId = (UUID) SpecialSerializers.UUIDSerializer.INSTANCE.fromBinary(buf, Optional.absent()); int clearId = buf.readInt(); int chunkNo = buf.readInt(); int bytes = buf.readInt(); int length = FlowManager.CHUNK_SIZE; boolean isFinal = false; if (!fields.flag2) { length = buf.readInt();// w w w . j a va 2 s .c o m isFinal = buf.readBoolean(); } ClearFlowId id = new ClearFlowId(flowId, clearId); ChunkCollector coll = ChunkCollector.collectors.get(id); if (coll == null) { coll = new ChunkCollector(flowId, clearId, bytes); ChunkCollector.collectors.put(id, coll); } ByteArrayRef data = coll.readChunk(chunkNo, length, buf); return new Chunk(fields.src, fields.dst, fields.proto, flowId, clearId, chunkNo, bytes, data, isFinal); }
From source file:se.sics.caracaldb.global.LookupSerializer.java
License:Open Source License
@Override public Object fromBinary(ByteBuf buf, Optional<Object> hint) { MessageFields fields = SpecialSerializers.MessageSerializationUtil.msgFromBinary(buf); if (matches(fields, FORWARD)) { Key key = CustomSerialisers.deserialiseKey(buf); Forwardable msg = (Forwardable) Serializers.fromBinary(buf, Optional.absent()); return new ForwardMessage(fields.src, fields.dst, fields.orig, fields.proto, key, msg); }// ww w . ja v a 2 s . c o m if (matches(fields, REQUEST)) { int n = buf.readInt(); boolean schema = buf.readBoolean(); return new SampleRequest(fields.src, fields.dst, n, schema); } if (matches(fields, SAMPLE)) { int size = buf.readInt(); ImmutableSet.Builder<Address> builder = ImmutableSet.builder(); for (int i = 0; i < size; i++) { Address addr = (Address) SpecialSerializers.AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent()); builder.add(addr); } int schemaL = buf.readInt(); if (schemaL < 0) { return new Sample(fields.src, fields.dst, builder.build(), null); } byte[] schemaData = new byte[schemaL]; buf.readBytes(schemaData); return new Sample(fields.src, fields.dst, builder.build(), schemaData); } if (matches(fields, SCHEMA)) { byte[] flagsB = new byte[1]; buf.readBytes(flagsB); boolean[] flags = BitBuffer.extract(8, flagsB); if (matches(flags, CREATE)) { SingleSchema schema = deserialiseSchema(buf); return new Schema.CreateReq(fields.src, fields.dst, fields.orig, schema.name, schema.meta); } if (matches(flags, DROP)) { int nameL = buf.readInt(); byte[] nameB = new byte[nameL]; buf.readBytes(nameB); String name = new String(nameB, SchemaData.CHARSET); return new Schema.DropReq(fields.src, fields.dst, fields.orig, name); } if (matches(flags, RESP)) { int nameL = buf.readInt(); byte[] nameB = new byte[nameL]; buf.readBytes(nameB); String name = new String(nameB, SchemaData.CHARSET); int idL = buf.readInt(); byte[] id = null; if (idL >= 0) { id = new byte[idL]; buf.readBytes(id); } int msgL = buf.readInt(); String msg = null; if (msgL >= 0) { byte[] msgB = new byte[msgL]; buf.readBytes(msgB); msg = new String(msgB, SchemaData.CHARSET); } return new Schema.Response(fields.src, fields.dst, name, id, flags[2], msg); } } LOG.warn("Don't know how to deserialise fields: {}", fields); return null; }
From source file:se.sics.ktoolbox.croupier.example.network.PeerViewASerializer.java
License:Open Source License
@Override public Object fromBinary(ByteBuf buf, Optional<Object> hint) { boolean flag = buf.readBoolean(); return new PeerViewA(flag); }
From source file:se.sics.nstream.torrent.conn.msg.NetCloseTransferSerializer.java
License:Open Source License
@Override public Object fromBinary(ByteBuf buf, Optional<Object> hint) { Identifier msgId = (Identifier) Serializers.lookupSerializer(msgIdType).fromBinary(buf, hint); FileId fileId = (FileId) Serializers.lookupSerializer(FileId.class).fromBinary(buf, hint); boolean leecher = buf.readBoolean(); return new NetCloseTransfer(msgId, fileId, leecher); }
From source file:sqr.entity.EntityFakePlayer.java
License:Open Source License
@Override public void readSpawnData(ByteBuf additionalData) { username = (String) ByteBufIO.readObject(additionalData); isContributor = additionalData.readBoolean(); setupCustomSkin();//www . jav a2s . c o m }