How to use the vscode-jsonrpc.createMessageConnection function in vscode-jsonrpc

To help you get started, we’ve selected a few vscode-jsonrpc 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 gfrancischini / vscode-unit-test / src / mochaTestLanguageServer / testRunner / client.ts View on Github external
private createConnection(reader : MessageReader, writer : MessageWriter): IConnection {
        // Use stdin and stdout for communication:
        let msgConnection = createMessageConnection(reader, writer);

        let result: IConnection = {
            listen: (): void => msgConnection.listen(),
            initialize: (params: RunParams) => msgConnection.sendRequest(RunRequest.type, params),
            onTestSuiteUpdated: (handler) => msgConnection.onNotification(TestSuiteUpdateNotification.type, handler),
            //onDataOutput: (handler) => msgConnection.onNotification(DataOutputNotification.type, handler),
            onClose: (handler)  => msgConnection.onClose(handler),
            onError: (handler)  => msgConnection.onError(handler),
        }

        return result;
    }
github eclipse-theia / theia / packages / core / src / node / messaging / ipc-bootstrap.ts View on Github external
* https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/

import 'reflect-metadata';
import { ConsoleLogger } from 'vscode-ws-jsonrpc/lib/logger';
import { createMessageConnection, IPCMessageReader, IPCMessageWriter, Trace } from 'vscode-jsonrpc';
import { checkParentAlive, ipcEntryPoint, IPCEntryPoint } from './ipc-protocol';

checkParentAlive();

const reader = new IPCMessageReader(process);
const writer = new IPCMessageWriter(process);
const logger = new ConsoleLogger();
const connection = createMessageConnection(reader, writer, logger);
connection.trace(Trace.Off, {
    // tslint:disable-next-line:no-any
    log: (message: any, data?: string) => console.log(message, data)
});

const entryPoint = require(ipcEntryPoint!).default as IPCEntryPoint;
entryPoint(connection);
github yitzchak / dicy / packages / server / spec / Server_spec.ts View on Github external
'setUserOptions'
    ])

    // @ts-ignore
    cache.on.and.callFake((name: string, handler: (file: Uri, messages: Message[]) => void) => {
      log = handler
      return cache
    })

    // @ts-ignore
    cache.run.and.returnValue(true)

    // @ts-ignore
    cache.getTargets.and.returnValue(['file://foo/bar.pdf'])

    client = rpc.createMessageConnection(clientTransport[0], clientTransport[1])
    client.listen()

    server = new Server(serverTransport, cache)
    server.start()
  })
github eclipse-theia / theia / packages / core / src / node / messaging / ipc-connection-provider.ts View on Github external
protected createConnection(childProcess: cp.ChildProcess, options: ResolvedIPCConnectionOptions): MessageConnection {
        const reader = new IPCMessageReader(childProcess);
        const writer = new IPCMessageWriter(childProcess);
        const connection = createMessageConnection(reader, writer, {
            error: (message: string) => this.logger.error(`[${options.serverName}: ${childProcess.pid}] ${message}`),
            warn: (message: string) => this.logger.warn(`[${options.serverName}: ${childProcess.pid}] ${message}`),
            info: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`),
            log: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`)
        });
        connection.trace(Trace.Off, {
            // tslint:disable-next-line:no-any
            log: (message: any, data?: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : ''))
        });
        return connection;
    }
github gfrancischini / vscode-unit-test / src / mochaTestLanguageServer / testRunner / server.ts View on Github external
private createConnection(reader, writer) {
        let msgConnection = createMessageConnection(reader, writer);

        let result: IConnection = {
            listen: (): void => msgConnection.listen(),
            onRun: (handler) => msgConnection.onRequest(RunRequest.type, handler),
            testSuiteUpdate: (params: TestSuiteUpdateParams) => msgConnection.sendNotification(TestSuiteUpdateNotification.type, params),
            //dataOutput: (params: DataOutputParams) => msgConnection.sendNotification(DataOutputNotification.type, params)
        }

        return result;
    }
github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / proxy.ts View on Github external
const server = net.createServer(socket => {
      this.initialized = false;
      server.close();
      this.currentServer = null;
      socket.on('close', () => this.onSocketClosed());
      this.eventEmitter.off('changePort', server.close);
      this.logger.info('langserver connection established on port ' + this.targetPort);
      const reader = new SocketMessageReader(socket);
      const writer = new SocketMessageWriter(socket);
      this.clientConnection = createMessageConnection(reader, writer, this.logger);
      this.registerOnNotificationHandler(this.clientConnection);
      this.clientConnection.listen();
      this.eventEmitter.emit('connect');
    });
    server.on('error', this.setError);
github elastic / kibana / x-pack / plugins / code / server / lsp / proxy.ts View on Github external
const server = net.createServer(socket => {
          this.initialized = false;
          server.close();
          this.eventEmitter.emit('connect');
          socket.on('close', () => this.onSocketClosed());

          this.logger.info('langserver connection established on port ' + this.targetPort);

          const reader = new SocketMessageReader(socket);
          const writer = new SocketMessageWriter(socket);
          this.clientConnection = createMessageConnection(reader, writer, this.logger);
          this.registerOnNotificationHandler(this.clientConnection);
          this.clientConnection.listen();
          res(this.clientConnection);
        });
        server.on('error', rej);
github eclipse-theia / theia / src / messaging / common / socket / connection.ts View on Github external
export function createSocketConnection(socket: Socket, logger: Logger): MessageConnection {
    const messageReader = new SocketMessageReader(socket);
    const messageWriter = new SocketMessageWriter(socket);
    const connection = createMessageConnection(messageReader, messageWriter, logger);
    connection.trace(Trace.Off, logger);
    connection.onClose(() => connection.dispose());
    return connection;
}