package com.munjaon.client.server.packet;

import java.nio.ByteBuffer;

public final class LinkCheck {
    public static final int LINK_CHECK_BODY_LENGTH = 3;
    public static final int LINK_CHECK_BODY_POSITION = Header.BODY_POSITION + Header.BODY_LENGTH;
    public static final int LINK_CHECK_ACK_BODY_LENGTH = 3;
    public static final int LINK_CHECK_ACK_BODY_POSITION = Header.BODY_POSITION + Header.BODY_LENGTH;

    public static String LINK_CHECK_VALUE = "100";
    public static String LINK_CHECK_ACK_VALUE = "100";

    public static ByteBuffer makeLinkCheckBuffer() {
        ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + LINK_CHECK_BODY_LENGTH);
        Packet.setDefaultByte(buffer);
        Header.putHeader(buffer, Header.COMMAND_LINK_CHECK, LINK_CHECK_BODY_LENGTH);
        buffer.put(LINK_CHECK_BODY_POSITION, LINK_CHECK_VALUE.getBytes());

        return buffer;
    }

    public static ByteBuffer makeLinkCheckAckBuffer() {
        ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + LINK_CHECK_ACK_BODY_LENGTH);
        Packet.setDefaultByte(buffer);
        Header.putHeader(buffer, Header.COMMAND_LINK_CHECK_ACK, LINK_CHECK_ACK_BODY_LENGTH);
        buffer.put(LINK_CHECK_ACK_BODY_POSITION, LINK_CHECK_ACK_VALUE.getBytes());

        return buffer;
    }
}
