UNPKG

raas-client

Version:
59 lines 3.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Common { static sendSimpleRequest(connection, messageType, payload, timeout, timeoutMessage) { return new Promise((resolve, reject) => { const timer = setTimeout(() => { reject(new Error(timeoutMessage)); }, timeout); return connection.sendRequest(messageType, payload).then(result => { clearTimeout(timer); resolve(result); }); }); } static sendRequestSync(connection, messageType, payload, emitter, eventId, listener, timeout, timeoutMessage) { return new Promise((resolve, reject) => { const timer = setTimeout(() => { return reject(new Error(timeoutMessage)); }, timeout); let response; const handler = (params) => { if (listener(params)) { response.then(() => { clearTimeout(timer); emitter.removeListener(eventId, listener); resolve(params); }); } }; emitter.prependListener(eventId, handler); response = connection.sendRequest(messageType, payload); }); } static sendSimpleNotification(connection, messageType, payload) { connection.sendNotification(messageType, payload); } } exports.Common = Common; var ErrorMessages; (function (ErrorMessages) { ErrorMessages.ADDINSTALLABLE_TIMEOUT = 'Failed to add installable server in time'; ErrorMessages.UPDATEINSTALLABLE_TIMEOUT = 'Failed to update installable server in time'; ErrorMessages.DELETEINSTALLABLE_TIMEOUT = 'Failed to delete installable server in time'; ErrorMessages.GETALLINSTALLABLESERVERS_TIMEOUT = 'Failed to retrieve all installable servers in time'; ErrorMessages.ADDINSTALLEDSERVER_TIMEOUT = 'Failed to add installed server in time'; ErrorMessages.INSTALLSERVER_TIMEOUT = 'Failed to install server in time'; ErrorMessages.CANCELINSTALLION_TIMEOUT = 'Failed to cancel server installation in time'; ErrorMessages.DELETEINSTALLION_TIMEOUT = 'Failed to delete server installation in time'; ErrorMessages.UPDATEINSTALLATION_TIMEOUT = 'Failed to update server installation in time'; ErrorMessages.GETALLINSTALLEDSERVERS_TIMEOUT = 'Failed to retrieve all installed servers in time'; ErrorMessages.GETALLINSTALLINGSERVERS_TIMEOUT = 'Failed to retrieve all installing servers in time'; ErrorMessages.STARTSERVER_TIMEOUT = 'Failed to start server in time'; ErrorMessages.STOPSERVER_TIMEOUT = 'Failed to stop server in time'; ErrorMessages.STARTANALYSIS_TIMEOUT = 'Failed to start analysis in time'; ErrorMessages.CANCELANALYSIS_TIMEOUT = 'Failed to cancel analysis in time'; ErrorMessages.GETALLANALYSES_TIMEOUT = 'Failed to retrieve all analyses in time'; ErrorMessages.GETALLSERVERHANDLES_TIMEOUT = 'Failed to retrieve all analyses in time'; })(ErrorMessages = exports.ErrorMessages || (exports.ErrorMessages = {})); //# sourceMappingURL=common.js.map