How to use the rsp-client.ServerState.STARTED function in rsp-client

To help you get started, we’ve selected a few rsp-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redhat-developer / vscode-rsp-ui / src / extensionApi.ts View on Github external
await rspProvider.stopRSP().catch(err => {
                    // if stopRSP fails, server is still running
                    this.explorer.updateRSPServer(context.type.id, ServerState.STARTED);
                    return Promise.reject(`Failed to terminate ${context.type.visibilename} - ${err}`);
                });
            }
github redhat-developer / vscode-rsp-ui / test / protocolstubs.ts View on Github external
public static readonly rspState: RSPState = {
        serverStates: [ProtocolStubs.startedServerState],
        state: ServerState.UNKNOWN,
        type: ProtocolStubs.rspType
    };

    public static readonly rspProperties: RSPProperties = {
        client: undefined,
        rspserverstderr: undefined,
        rspserverstdout: undefined,
        state: ProtocolStubs.rspState
    };

    public static readonly rspStateStarted: RSPState = {
        serverStates: [],
        state: ServerState.STARTED,
        type: ProtocolStubs.rspType
    };

    public static readonly createResponseOK: Protocol.CreateServerResponse = {
        status: ProtocolStubs.okStatus,
        invalidKeys: []
    };

    public static readonly createResponseKO: Protocol.CreateServerResponse = {
        status: ProtocolStubs.errorStatus,
        invalidKeys: []
    };

    public static readonly updateServerResponse: Protocol.UpdateServerResponse = {
        handle: ProtocolStubs.serverHandle,
        validation: ProtocolStubs.createResponseOK,
github redhat-developer / vscode-rsp-ui / test / protocolstubs.ts View on Github external
public static readonly unknownServerState: ServerStateNode =  {
        server: ProtocolStubs.serverHandle,
        deployableStates: [],
        publishState: ServerState.PUBLISH_STATE_UNKNOWN,
        runMode: ServerState.RUN_MODE_RUN,
        state: ServerState.UNKNOWN,
        rsp: 'id'
    };

    public static readonly startedServerStateProtocol: Protocol.ServerState = {
        deployableStates: [],
        publishState: ServerState.PUBLISH_STATE_UNKNOWN,
        server: ProtocolStubs.serverHandle,
        runMode: ServerState.RUN_MODE_RUN,
        state: ServerState.STARTED
    };

    public static readonly deployableReference: Protocol.DeployableReference = {
        label: 'fake',
        path: 'fakepath'
    };

    public static readonly deployableStateNode: DeployableStateNode = {
        rsp: 'id',
        publishState: ServerState.PUBLISH_STATE_UNKNOWN,
        server: ProtocolStubs.serverHandle,
        state: ServerState.STARTED,
        reference: ProtocolStubs.deployableReference
    };

    public static readonly startedServerState: ServerStateNode = {
github redhat-developer / vscode-rsp-ui / src / extensionApi.ts View on Github external
public async stopServer(forced: boolean, context?: ServerStateNode): Promise {
        if (context === undefined) {
            const rsp = await this.selectRSP('Select RSP provider you want to retrieve servers');
            if (!rsp || !rsp.id) return null;
            const serverFilter = server => server.state === ServerState.STARTED;
            const serverId = await this.selectServer(rsp.id, 'Select server to stop.', serverFilter);
            if (!serverId) return null;
            context = this.explorer.getServerStateById(rsp.id, serverId);
        }

        const serverState = this.explorer.getServerStateById(context.rsp, context.server.id).state;
        if ((!forced && serverState === ServerState.STARTED)
            || (forced && (serverState === ServerState.STARTING
                            || serverState === ServerState.STOPPING))) {
            const client: RSPClient = this.explorer.getClientByRSP(context.rsp);
            if (!client) {
                return Promise.reject('Failed to contact the RSP server.');
            }
            const status = await client.getOutgoingHandler().stopServerAsync(
                { id: context.server.id, force: forced }
            );
            if (this.debugSession.isDebuggerStarted()) {
                await this.debugSession.stop();
            }
            if (!StatusSeverity.isOk(status)) {
                return Promise.reject(status.message);
            }
            return status;