Example usage for io.netty.buffer ByteBuf writeByte

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

Introduction

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

Prototype

public abstract ByteBuf writeByte(int value);

Source Link

Document

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

Usage

From source file:de.gandev.modjn.entity.func.request.WriteMultipleCoilsRequest.java

License:Apache License

@Override
public ByteBuf encode() {
    ByteBuf buf = super.encode();

    buf.writeByte(byteCount);
    buf.writeBytes(outputsValue.toByteArray());

    return buf;/*w ww  .j  a  va 2  s. c  o  m*/
}

From source file:de.gandev.modjn.entity.func.request.WriteMultipleRegistersRequest.java

License:Apache License

@Override
public ByteBuf encode() {
    ByteBuf buf = super.encode();

    buf.writeByte(byteCount);

    for (int i = 0; i < registers.length; i++) {
        buf.writeShort(registers[i]);//from  w  w w  .j  ava 2 s  .c om
    }

    return buf;
}

From source file:de.gandev.modjn.entity.func.response.ReadCoilsResponse.java

License:Apache License

@Override
public ByteBuf encode() {
    ByteBuf buf = Unpooled.buffer(calculateLength());
    buf.writeByte(getFunctionCode());
    buf.writeByte(byteCount);//from   w  w  w.j  ava  2  s.c  om
    buf.writeBytes(coilStatus.toByteArray());

    return buf;
}

From source file:de.gandev.modjn.entity.func.response.ReadDiscreteInputsResponse.java

License:Apache License

@Override
public ByteBuf encode() {
    ByteBuf buf = Unpooled.buffer(calculateLength());
    buf.writeByte(getFunctionCode());
    buf.writeByte(byteCount);//  w  w  w. j  a  v a  2  s . c  o  m
    buf.writeBytes(inputStatus.toByteArray());

    return buf;
}

From source file:de.gandev.modjn.entity.func.response.ReadHoldingRegistersResponse.java

License:Apache License

@Override
public ByteBuf encode() {
    ByteBuf buf = Unpooled.buffer(calculateLength());
    buf.writeByte(getFunctionCode());
    buf.writeByte(byteCount);//from w w w  .  j a  v  a  2 s .  c  o  m

    for (int i = 0; i < registers.length; i++) {
        buf.writeShort(registers[i]);
    }

    return buf;
}

From source file:de.gandev.modjn.entity.func.response.ReadInputRegistersResponse.java

License:Apache License

@Override
public ByteBuf encode() {
    ByteBuf buf = Unpooled.buffer(calculateLength());
    buf.writeByte(getFunctionCode());
    buf.writeByte(byteCount);//ww  w.  j  a v a 2  s . c  om

    for (int i = 0; i < inputRegisters.length; i++) {
        buf.writeShort(inputRegisters[i]);
    }

    return buf;
}

From source file:de.jackwhite20.cascade.shared.pipeline.handler.PacketEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, Packet packet, List<Object> out) throws Exception {

    try {/*from   w ww  .j a  va2  s  . co  m*/
        byte id = protocol.findId(packet.getClass());

        ByteBuf byteBuf = ctx.alloc().buffer();
        byteBuf.writeByte(id);
        packet.write(byteBuf);

        out.add(byteBuf);
    } catch (IllegalStateException e) {
        ctx.fireExceptionCaught(e);
    }
}

From source file:de.jackwhite20.comix.network.Protocol.java

License:Open Source License

public static void writeVarInt(int value, ByteBuf output) {
    int part;//from   w  w w.  j a  va 2s . c  om
    while (true) {
        part = value & 0x7F;

        value >>>= 7;
        if (value != 0) {
            part |= 0x80;
        }

        output.writeByte(part);

        if (value == 0) {
            break;
        }
    }
}

From source file:de.jackwhite20.hftp.shared.packet.DeleteFileResultPacket.java

License:Open Source License

@Override
public void write(ByteBuf byteBuf) throws Exception {

    byteBuf.writeByte(result.ordinal());
}