1 line
1.9 KiB
JavaScript
1 line
1.9 KiB
JavaScript
"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},e=function(){function t(t,e){for(var i in e){var r=e[i];r.configurable=!0,r.value&&(r.writable=!0)}Object.defineProperties(t,e)}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),i=function c(t,e,i){var r=Object.getOwnPropertyDescriptor(t,e);if(void 0===r){var o=Object.getPrototypeOf(t);return null===o?void 0:c(o,e,i)}if("value"in r&&r.writable)return r.value;var n=r.get;if(void 0!==n)return n.call(i)},r=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},n=t(require("uuid")),a=t(require("./asr-vars")),s=require("events").EventEmitter,u=function(t){function s(t){o(this,s),i(Object.getPrototypeOf(s.prototype),"constructor",this).call(this),this.httpInterface=t,this.id="action-"+n.v4(),a.idToAction[this.id]=this,this.isCleared=!1}return r(s,t),e(s,{setAudioSourceId:{value:function(t){this.audioSourceId=t}},start:{value:function(t){if(!this.isCleared){var e={action:"init_and_start",task:t,task_id:this.id,audio_source_id:this.audioSourceId};e=JSON.stringify(e);var i=new XMLHttpRequest;i.open("POST",this.httpInterface,!0),i.send(e)}}},stop:{value:function(){if(!this.isCleared){var t=new XMLHttpRequest,e={action:"stop",task:"",task_id:this.id,audio_source_id:this.audioSourceId};e=JSON.stringify(e),t.open("POST",this.httpInterface,!0),t.send(e)}}},clear:{value:function(){if(!this.isCleared){delete a.idToAction[this.id],this.isCleared=!0;var t=new XMLHttpRequest,e={action:"clear",task:"",task_id:this.id,audio_source_id:this.audioSourceId};e=JSON.stringify(e),t.open("POST",this.httpInterface,!0),t.send(e)}}}}),s}(s);module.exports=u; |