2023-06-29 10:09:28 +00:00
|
|
|
cqi.CQiClient = class CQiClient {
|
|
|
|
/**
|
|
|
|
* @param {string} host
|
2023-06-30 12:13:34 +00:00
|
|
|
* @param {number} [timeout=60] timeout
|
2023-06-29 10:09:28 +00:00
|
|
|
* @param {string} [version=0.1] version
|
|
|
|
*/
|
2023-07-13 10:42:47 +00:00
|
|
|
constructor(host, timeout = 60, version = '0.1') {
|
2023-06-29 10:09:28 +00:00
|
|
|
/** @type {cqi.api.APIClient} */
|
2023-07-13 10:42:47 +00:00
|
|
|
this.api = new cqi.api.APIClient(host, timeout, version);
|
2023-06-29 10:09:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {cqi.models.corpora.CorpusCollection}
|
|
|
|
*/
|
|
|
|
get corpora() {
|
|
|
|
return new cqi.models.corpora.CorpusCollection(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Promise<cqi.status.StatusByeOk>}
|
|
|
|
*/
|
|
|
|
async bye() {
|
|
|
|
return await this.api.ctrl_bye();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} username
|
|
|
|
* @param {string} password
|
|
|
|
* @returns {Promise<cqi.status.StatusConnectOk>}
|
|
|
|
*/
|
|
|
|
async connect(username, password) {
|
|
|
|
return await this.api.ctrl_connect(username, password);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Promise<cqi.status.StatusPingOk>}
|
|
|
|
*/
|
|
|
|
async ping() {
|
|
|
|
return await this.api.ctrl_ping();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Promise<null>}
|
|
|
|
*/
|
|
|
|
async userAbort() {
|
|
|
|
return await this.api.ctrl_user_abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias for "bye" method
|
|
|
|
*
|
|
|
|
* @returns {Promise<cqi.status.StatusByeOk>}
|
|
|
|
*/
|
|
|
|
async disconnect() {
|
|
|
|
return await this.api.ctrl_bye();
|
|
|
|
}
|
|
|
|
};
|