Object.defineProperty(exports, "__esModule", { value: true });
var MittiClass_1 = require("./MittiClass");
var axios = require('axios').default;
module.exports = function (api) {
    //Register a action
    api.registerAction('clip', require('./actions/clip'));
    api.registerAction('play', require('./actions/play'));
    api.registerAction('stop', require('./actions/stop'));
    api.registerAction('next', require('./actions/next'));
    api.registerAction('previous', require('./actions/previous'));
    api.registerConnectionValidator('mitti', function (ValidatorAPI) {
        var properties = ValidatorAPI.properties;
        if (properties.ip != undefined) {
            if (ValidatorAPI.instance != undefined && ValidatorAPI.instance.connected == true)
                return ValidatorAPI.callback(true);
            var mitti = new MittiClass_1.Mitti(properties.ip);
            var canRespond = true;
            var timeout = setTimeout(function () {
                canRespond = false;
                ValidatorAPI.callback(false, 'Timeout while trying to connect to Mitti');
            }, 3000);
            mitti.on('connected', function () {
                if (canRespond == true) {
                    canRespond = false;
                    ValidatorAPI.setInstance(mitti);
                    clearTimeout(timeout);
                    ValidatorAPI.callback(true);
                }
            });
            mitti.on('connecterror', function (errorMessage) {
                if (canRespond == true) {
                    canRespond = false;
                    clearTimeout(timeout);
                    ValidatorAPI.callback(false, errorMessage);
                }
            });
        }
        else
            ValidatorAPI.callback(false, 'Incorrect ip address syntax');
    });
};
//# sourceMappingURL=mitti.js.map