package at.acdp.urweb.rtde.packets;

import at.acdp.urweb.rtde.CommandType;
import at.acdp.urweb.rtde.RTDEClient;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import static at.acdp.urweb.rtde.CommandType.RTDE_REQUEST_PROTOCOL_VERSION;

public class RtdeRequestProtocolVersion implements IRtdeData {
    public boolean success;
    private int replySize;

    public RtdeRequestProtocolVersion() {
    }

    @Override
    public int getType() {
        return RTDE_REQUEST_PROTOCOL_VERSION;
    }

    @Override
    public int getSize() {
        return 5;
    }

    @Override
    public void setReplySize(int size) {
        this.replySize = size;
    }

    @Override
    public RtdeRequestProtocolVersion read(DataInputStream d) throws IOException {
        success = d.readBoolean();
        return this;
    }

    @Override
    public RtdeRequestProtocolVersion send(DataOutputStream dos) throws IOException {
        sendHeader(dos);
        dos.writeShort(RTDEClient.RTDE_PROTOCOL_VERSION);
        dos.flush();
        return this;
    }
}
