This package has been deprecated

    Author message:

    Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

    @codingame/monaco-jsonrpc
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.1 • Public • Published

    ⚠️ @CodinGame/monaco-jsonrpc is deprecated.

    Use vscode-ws-jsonrpc instead

    VSCode WebSocket JSON RPC

    NPM module to implement communication between a jsonrpc client and server over WebSocket.

    Client side connection handling

    import * as rpc from 'monaco-jsonrpc';
    
    const webSocket = new WebSocket('ws://www.example.com/socketserver');
    rpc.listen({
        webSocket,
        onConnection: (connection: rpc.MessageConnection) => {
            const notification = new rpc.NotificationType<string, void>('testNotification');
            connection.listen();
            connection.sendNotification(notification, 'Hello World');
        }
    });

    Server side connection handling

    import * as rpc from 'monaco-jsonrpc';
    
    const socket: rpc.IWebSocket; // open the web socket
    const reader = new rpc.WebSocketMessageReader(socket);
    const writer = new rpc.WebSocketMessageWriter(socket);
    const logger = new rpc.ConsoleLogger();
    const connection = rpc.createMessageConnection(reader, writer, logger);
    const notification = new rpc.NotificationType<string, void>('testNotification');
    connection.onNotification(notification, (param: string) => {
    	console.log(param); // This prints Hello World
    });
    
    connection.listen();

    Server side connection forwarding

    import * as rpc from 'monaco-jsonrpc';
    import * as server from 'monaco-jsonrpc/lib/server';
    
    const socket: rpc.IWebSocket; // open the web socket
    const reader = new rpc.WebSocketMessageReader(socket);
    const writer = new rpc.WebSocketMessageWriter(socket);
    const socketConnection = server.createConnection(reader, writer, () => socket.dispose())
    const serverConnection = server.createServerProcess('Example', 'node', ['example.js']);
    server.forward(socketConnection, serverConnection, message => {
        if (rpc.isNotificationMessage(message)) {
            if (message.method === 'testNotification') {
                // handle the test notification
            }
        }
        return message;
    });

    License

    MIT

    Keywords

    none

    Install

    npm i @codingame/monaco-jsonrpc

    DownloadsWeekly Downloads

    1,887

    Version

    0.4.1

    License

    MIT

    Unpacked Size

    50 kB

    Total Files

    53

    Last publish

    Collaborators

    • beli4l
    • codingame_team
    • maximecg
    • nantoniazzi
    • nonofr
    • samuel.olivier