Example usage for io.netty.buffer ByteBuf writeBoolean

List of usage examples for io.netty.buffer ByteBuf writeBoolean

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeBoolean.

Prototype

public abstract ByteBuf writeBoolean(boolean value);

Source Link

Document

Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.

Usage

From source file:se.sics.caracaldb.global.LookupSerializer.java

License:Open Source License

@Override
public void toBinary(Object o, ByteBuf buf) {
    if (o instanceof ForwardMessage) {
        ForwardMessage msg = (ForwardMessage) o;
        SpecialSerializers.MessageSerializationUtil.msgToBinary(msg, buf, FORWARD[0], FORWARD[1]);
        CustomSerialisers.serialiseKey(msg.forwardTo, buf);
        Serializers.toBinary(msg.msg, buf);
        return;//  ww w  .  ja v  a 2 s  .c o  m
    }
    if (o instanceof SampleRequest) {
        SampleRequest msg = (SampleRequest) o;
        SpecialSerializers.MessageSerializationUtil.msgToBinary(msg, buf, REQUEST[0], REQUEST[1]);
        buf.writeInt(msg.n);
        buf.writeBoolean(msg.schema);
        return;
    }
    if (o instanceof Sample) {
        Sample msg = (Sample) o;
        SpecialSerializers.MessageSerializationUtil.msgToBinary(msg, buf, SAMPLE[0], SAMPLE[1]);
        buf.writeInt(msg.nodes.size());
        for (Address addr : msg.nodes) {
            SpecialSerializers.AddressSerializer.INSTANCE.toBinary(addr, buf);
        }
        if (msg.schemaData == null) {
            buf.writeInt(-1);
            return;
        }
        buf.writeInt(msg.schemaData.length);
        buf.writeBytes(msg.schemaData);
        return;
    }
    if (o instanceof Schema.CreateReq) {
        Schema.CreateReq msg = (Schema.CreateReq) o;
        SpecialSerializers.MessageSerializationUtil.msgToBinary(msg, buf, SCHEMA[0], SCHEMA[1]);
        BitBuffer flags = BitBuffer.create(CREATE);
        byte[] flagsB = flags.finalise();
        buf.writeBytes(flagsB);
        SchemaData.serialiseSchema(buf, ByteBuffer.wrap(new byte[0]), msg.name, msg.metaData);
        return;
    }
    if (o instanceof Schema.DropReq) {
        Schema.DropReq msg = (Schema.DropReq) o;
        SpecialSerializers.MessageSerializationUtil.msgToBinary(msg, buf, SCHEMA[0], SCHEMA[1]);
        BitBuffer flags = BitBuffer.create(DROP);
        byte[] flagsB = flags.finalise();
        buf.writeBytes(flagsB);
        byte[] nameB = msg.name.getBytes(SchemaData.CHARSET);
        buf.writeInt(nameB.length);
        buf.writeBytes(nameB);
        return;
    }
    if (o instanceof Schema.Response) {
        Schema.Response msg = (Schema.Response) o;
        SpecialSerializers.MessageSerializationUtil.msgToBinary(msg, buf, SCHEMA[0], SCHEMA[1]);
        BitBuffer flags = BitBuffer.create(RESP);
        flags.write(msg.success);
        byte[] flagsB = flags.finalise();
        buf.writeBytes(flagsB);
        byte[] nameB = msg.name.getBytes(SchemaData.CHARSET);
        buf.writeInt(nameB.length);
        buf.writeBytes(nameB);
        if (msg.id == null) {
            buf.writeInt(-1);
        } else {
            buf.writeInt(msg.id.length);
            buf.writeBytes(msg.id);
        }
        if (msg.msg == null) {
            buf.writeInt(-1);
        } else {
            byte[] msgB = msg.msg.getBytes(SchemaData.CHARSET);
            buf.writeInt(msgB.length);
            buf.writeBytes(msgB);
        }
        return;
    }
    LOG.warn("Couldn't serialize {}: {}", o, o.getClass());
}

From source file:se.sics.ktoolbox.croupier.example.network.PeerViewASerializer.java

License:Open Source License

@Override
public void toBinary(Object o, ByteBuf buf) {
    PeerViewA obj = (PeerViewA) o;
    buf.writeBoolean(obj.flag);
}

From source file:se.sics.nstream.torrent.conn.msg.NetCloseTransferSerializer.java

License:Open Source License

@Override
public void toBinary(Object o, ByteBuf buf) {
    NetCloseTransfer obj = (NetCloseTransfer) o;
    Serializers.lookupSerializer(msgIdType).toBinary(obj.msgId, buf);
    Serializers.lookupSerializer(FileId.class).toBinary(obj.fileId, buf);
    buf.writeBoolean(obj.leecher);
}

From source file:sqr.entity.EntityFakePlayer.java

License:Open Source License

@Override
public void writeSpawnData(ByteBuf buffer) {
    ByteBufIO.writeObject(buffer, username);
    buffer.writeBoolean(isContributor);
}

From source file:sqr.entity.EntityOtherQueen.java

License:Open Source License

@Override
public void writeSpawnData(ByteBuf buffer) {
    buffer.writeBoolean(isHostile);
    buffer.writeInt(friendlySkinIndex);
}

From source file:thaumic.tinkerer.common.network.packet.kami.PacketWarpGateButton.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf byteBuf) {
    super.toBytes(byteBuf);
    byteBuf.writeBoolean(locked);
}

From source file:thaumic.tinkerer.common.network.packet.PacketMobMagnetButton.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf byteBuf) {
    super.toBytes(byteBuf);
    byteBuf.writeBoolean(adult);
}

From source file:thaumic.tinkerer.common.network.packet.PacketTabletButton.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf byteBuf) {
    super.toBytes(byteBuf);
    byteBuf.writeBoolean(leftClick);
    byteBuf.writeBoolean(redstone);//  ww w.ja  v  a 2  s  . co m
}

From source file:totemic_commons.pokefenn.network.block.music.DrumPacket.java

License:MIT License

@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    buffer.writeInt(x);//from  w ww  . j  av a  2  s .  co m
    buffer.writeInt(y);
    buffer.writeInt(z);
    buffer.writeBoolean(canPlay);
}

From source file:totemic_commons.pokefenn.network.client.PacketWindChime.java

License:MIT License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(x);
    buf.writeInt(y);
    buf.writeInt(z);
    buf.writeBoolean(isPlaying);
}