Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 1x 1x 1x 5x 5x 5x | import { MessageConnection } from 'vscode-jsonrpc';
import { EventEmitter } from 'events';
import { Messages, Protocol } from 'raas-core';
import { Common, ErrorMessages } from './common';
export class Installable {
private connection: MessageConnection;
private emitter: EventEmitter;
constructor(connection: MessageConnection, emitter: EventEmitter) {
this.connection = connection;
this.emitter = emitter;
this.listenToInstallableChanges();
}
private listenToInstallableChanges() {
this.connection.onNotification(Messages.Client.InstallableServerAddedNotification.type,
installableServer => {
this.emitter.emit('installableServerAdded', installableServer);
});
this.connection.onNotification(Messages.Client.InstallableServerUpdatedNotification.type,
installableServer => {
this.emitter.emit('installableServerUpdated', installableServer);
});
this.connection.onNotification(Messages.Client.InstallableServerDeletedNotification.type,
installableServer => {
this.emitter.emit('installableServerDeleted', installableServer);
});
}
addInstallable(installable: Protocol.InstallableServer, timeout: number = 2000): Promise<Protocol.Status> {
return this.send(Messages.Server.AddInstallableServerRequest.type, installable,
'installableServerAdded',
(param: Protocol.InstallableServer) => param.id === installable.id,
timeout, ErrorMessages.ADDINSTALLABLE_TIMEOUT);
}
updateInstallableServer(installable: Protocol.InstallableServer, timeout: number = 2000): Promise<Protocol.Status> {
return this.send(Messages.Server.UpdateInstallableServerRequest.type, installable,
'installableServerUpdated',
(param: Protocol.InstallableServer) => param.id === installable.id,
timeout, ErrorMessages.UPDATEINSTALLABLE_TIMEOUT);
}
deleteInstallableServer(installable: Protocol.InstallableServer, timeout: number = 2000): Promise<Protocol.Status> {
return this.send(Messages.Server.DeleteInstallableServerRequest.type, installable,
'installableServerDeleted',
(param: Protocol.InstallableServer) => param.id === installable.id,
timeout, ErrorMessages.DELETEINSTALLABLE_TIMEOUT);
}
getAllInstallableServers(timeout: number = 2000): Promise<Protocol.InstallableServer[]> {
return Common.sendSimpleRequest(this.connection, Messages.Server.GetInstallableServersRequest.type, null,
timeout, ErrorMessages.GETALLINSTALLABLESERVERS_TIMEOUT);
}
private send(messageType: any, payload: any, id: string,
listener: (params: any) => boolean, timeout: number,
timeoutMessage: string): Promise<Protocol.Status> {
return Common.sendRequestSync(this.connection, messageType,
payload, this.emitter, id, listener, timeout, timeoutMessage);
}
} |