raas-client
Version:
63 lines • 3.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const raas_core_1 = require("raas-core");
const common_1 = require("./common");
class Runtime {
constructor(connection, emitter) {
this.connection = connection;
this.emitter = emitter;
this.listenToRuntimeChanges();
}
listenToRuntimeChanges() {
this.connection.onNotification(raas_core_1.Messages.Client.StartingServerNotification.type, serverRunConfiguration => {
this.emitter.emit('startingServer', serverRunConfiguration);
});
this.connection.onNotification(raas_core_1.Messages.Client.ServerMessageNotification.type, data => {
this.emitter.emit('serverMessage', data);
});
this.connection.onNotification(raas_core_1.Messages.Client.ErrorStartingServerNotification.type, data => {
this.emitter.emit('errorStartingServer', data);
});
this.connection.onNotification(raas_core_1.Messages.Client.ServerStartedNotification.type, serverInstanceHandle => {
this.emitter.emit('serverStarted', serverInstanceHandle);
});
this.connection.onNotification(raas_core_1.Messages.Client.ServerStoppedNotification.type, serverInstanceHandle => {
this.emitter.emit('serverStopped', serverInstanceHandle);
});
this.connection.onNotification(raas_core_1.Messages.Client.AnalysisStartedNotification.type, analysis => {
this.emitter.emit('analysisStarted', analysis);
});
this.connection.onNotification(raas_core_1.Messages.Client.AnalysisCancelledNotification.type, analysis => {
this.emitter.emit('analysisCancelled', analysis);
});
this.connection.onNotification(raas_core_1.Messages.Client.AnalysisMessageNotification.type, data => {
this.emitter.emit('analysisMessage', data);
});
this.connection.onNotification(raas_core_1.Messages.Client.AnalysisCompletedNotification.type, data => {
this.emitter.emit('analysisComplete', data);
});
}
startServer(config, timeout = 60000) {
return this.send(raas_core_1.Messages.Server.StartServerRequest.type, config, 'serverStarted', (param) => param.runConfiguration.id === config.id, timeout, common_1.ErrorMessages.STARTSERVER_TIMEOUT);
}
stopServer(id, timeout = 60000) {
return this.send(raas_core_1.Messages.Server.StopServerRequest.type, id, 'serverStopped', (param) => param.id === id, timeout, common_1.ErrorMessages.STOPSERVER_TIMEOUT);
}
startAnalysis(config, timeout = 60000) {
return this.send(raas_core_1.Messages.Server.StartAnalaysisRequest.type, config, 'analysisStarted', (param) => param.analysisConfiguration.id === config.id, timeout, common_1.ErrorMessages.STARTANALYSIS_TIMEOUT);
}
cancelAnalysis(config, timeout = 60000) {
return this.send(raas_core_1.Messages.Server.CancelAnalaysisRequest.type, config, 'analysisCancelled', (param) => param.id === config.id, timeout, common_1.ErrorMessages.CANCELANALYSIS_TIMEOUT);
}
getAllAnalyses(timeout = 2000) {
return common_1.Common.sendSimpleRequest(this.connection, raas_core_1.Messages.Server.GetAllAnalysesRequest.type, null, timeout, common_1.ErrorMessages.GETALLANALYSES_TIMEOUT);
}
getAllServerHandles(timeout = 2000) {
return common_1.Common.sendSimpleRequest(this.connection, raas_core_1.Messages.Server.GetServerHandlesRequest.type, null, timeout, common_1.ErrorMessages.GETALLSERVERHANDLES_TIMEOUT);
}
send(messageType, payload, id, listener, timeout, timeoutMessage) {
return common_1.Common.sendRequestSync(this.connection, messageType, payload, this.emitter, id, listener, timeout, timeoutMessage);
}
}
exports.Runtime = Runtime;
//# sourceMappingURL=runtime.js.map