import axios from "axios";

export class Protor {
    ip: string;
    port: number;

    constructor(ip: string, port: number) {
        this.ip = ip;
        this.port = port;
    }

    _getBaseURI() {
        return `http://${this.ip}:${this.port}/`
    }

    isOnline(callback: (online: boolean) => void) {
        axios.get(this._getBaseURI() + 'online').then(() => {
            callback(true)
        }).catch(() => {
            callback(false)
        })
    }

    fadeIn(duration: number = 0) {
        axios.get(this._getBaseURI() + 'api/animation/fadein/' + duration).then(() => {

        }).catch(() => {

        })
    }

    fadeOut(duration: number = 0) {
        axios.get(this._getBaseURI() + 'api/animation/fadeout/' + duration).then(() => {

        }).catch(() => {

        })
    }
}