GithubHelp home page GithubHelp logo

typefox / vscode-ws-jsonrpc Goto Github PK

View Code? Open in Web Editor NEW
54.0 9.0 30.0 26 KB

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

Home Page: https://www.npmjs.com/package/vscode-ws-jsonrpc

License: MIT License

TypeScript 100.00%
json-rpc typescript websocket

vscode-ws-jsonrpc's Introduction

⚠️ vscode-ws-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 'vscode-ws-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 'vscode-ws-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 'vscode-ws-jsonrpc';
import * as server from 'vscode-ws-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

vscode-ws-jsonrpc's People

Contributors

akosyakov avatar kaisalmen avatar romannikitenko avatar spoenemann avatar svenefftinge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-ws-jsonrpc's Issues

ws-jsonrpc can not be compiled

I copied this file https://github.com/TypeFox/monaco-languageclient/blob/master/example/src/server.ts
and run compile local

$yarn compile

yarn run v1.5.1
$ installServerIntoExtension ./out ./package.json ./tsconfig.json && tsc -p .
Copying package.json to extension's server location...
Updating server npm modules into extension's server location...
node_modules/vscode-ws-jsonrpc/lib/connection.d.ts(4,16): error TS2304: Cannot find name 'WebSocket'.
node_modules/vscode-ws-jsonrpc/lib/connection.d.ts(8,45): error TS2304: Cannot find name 'WebSocket'.

I fixed this by adding this line in connection.d.ts

import * as WebSocket from "ws";

WebSocketMessageReader vs Content-Length

is there a reason why WebSocketMessageReader/Writer does not support Content-Length header as StreamMessageReader/Writer and SocketMessageReader/Writer do? Not even Optional with a flag?

This implies that both server and client aggree not to need/ignore them. this wont work e.g. on LSP4J that easy.

Send the data from the server side and receive it from the client side.

I have come across an issue that, I could not send the data from the server-side and receive it from the client-side.

I have used this code to send data from the Java server.

try {
            JsonDap jsonDap = new JsonDap();
            jsonDap.init();
            String text = jsonDap.encode(message);
            websocketSession.getBasicRemote().sendText(text);
        } catch (IOException e) {
            log.error("Error sending back a request to client", e);
        }

, But could not receive the data in the client-side, Also there were no errors in the serverside.
I have used this code to receive it from the client-side.

	private connectWebsocket() :void {
		var webSocket = new WebSocket('wss://localhost:9443/lsp/debug',{ rejectUnauthorized: false });
		this.webSocket = webSocket;
		console.log("Listening.. " );
		rpc.listen({
			webSocket,
			onConnection: (rpcConnection: rpc.MessageConnection) => {
				console.log("connected+ " );
				this.messageConnection = rpcConnection;
				let notification = new rpc.NotificationType<string, void>('breakpoint');

				rpcConnection.onNotification(notification, (param: any) => {
					console.log("got notificaiton breakpoint.. ");
					this.fireBreakpoint(param.line);
				});
				rpcConnection.onNotification( (param: any) => {
					console.log("got notificaiton any .. "+param );
				});
				rpcConnection.onRequest((param: any) => {
					console.log("got Request.. "+param );
				});

				rpcConnection.onError((param: any) => {
					console.log("got Request.. "+param );
				});

				rpcConnection.listen();
			}
		});

	}

is it an issue or I have an error in the implementations?

Reader doesn't handle binary data

If a message is received with binary data, the client will crash at this line:

const data = JSON.parse(message);

readMessage assumes that message is a string but it could also be binary data.

According to the WebSocket specification, the payload can be binary data depending on the opcode of the frame received:

   Opcode:  4 bits

      Defines the interpretation of the "Payload data".  If an unknown
      opcode is received, the receiving endpoint MUST _Fail the
      WebSocket Connection_.  The following values are defined.

      *  %x0 denotes a continuation frame

      *  %x1 denotes a text frame

      *  %x2 denotes a binary frame

      *  %x3-7 are reserved for further non-control frames

      *  %x8 denotes a connection close

      *  %x9 denotes a ping

      *  %xA denotes a pong

      *  %xB-F are reserved for further control frames

(https://datatracker.ietf.org/doc/rfc6455/)

Allow graceful termination with status code 1001

From RFC-6455:

1001

  1001 indicates that an endpoint is "going away", such as a server
  going down or a browser having navigated away from a page.

Related code:

if (code !== 1000) {
const error: Error = {
name: '' + code,
message: `Error during socket reconnect: code = ${code}, reason = ${reason}`
};
this.fireError(error);
}

Current behavior: fires on an error with the 1001 status code.
Expected behavior: do not fire error.

Upgrade Needed

Hello Community,

Seems like an upgrade is needed for this project to bump up dependencies:
vscode-jsonrpc: ^5.0.0 -> 6.0.0

Is there any planned release of an upgrade?

[quality] Align `DisposableCollection` with Theia?

The DisposableCollection is cool and convenient to use, however, what we have fixed in Theia never got back to here. Time to update or publish the DisposableCollection to npmjs and we do not have to copy-paste the code over and over.

See the diffs:

protected readonly disposables: Disposable[] = [];
dispose(): void {
while (this.disposables.length !== 0) {
this.disposables.pop()!.dispose();
}
}
push(disposable: Disposable): Disposable {
const disposables = this.disposables;
disposables.push(disposable);
return {
dispose(): void {
const index = disposables.indexOf(disposable);
if (index !== -1) {
disposables.splice(index, 1);
}
}
}
}
}

https://github.com/eclipse-theia/theia/blob/c4b4d3995ba81a80e36cd62d290dce2b23c8fd82/packages/core/src/common/disposable.ts#L38-L102

Unable to pass rootURI to palantir groovy language server

Sorry, for asking this naive question.
I am trying to integrate monacco-languageclient with groovy language server. I am getting below exception.
Either rootUri or rootPath must be set

I have tried setting up the rootUri to a dummy folder path
MonacoServices.install(editor, {rootUri: "file:///D:/git/monaco-languageclient/example/var"});

But still i am getting same error.

Please help me with this

Compile error: Module 'vscode-jsonrpc' has already exported a member named x

I get this error when building vscode-ws-jsonrpc:

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'ErrorCodes'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'Message'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'MessageType'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationMessage'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType0'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType1'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType2'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType3'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType4'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType5'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType6'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType7'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType8'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'NotificationType9'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestMessage'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType0'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType1'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType2'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType3'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType4'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType5'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType6'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType7'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType8'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'RequestType9'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:2:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'ResponseError'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from 'vscode-jsonrpc/lib/messages';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../felixfbecker/TypeFox/vscode-ws-jsonrpc/lib/index.d.ts:3:1 - error TS2308: Module 'vscode-jsonrpc' has already exported a member named 'Disposable'. Consider explicitly re-exporting to resolve the ambiguity.

3 export * from './disposable';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Usage in browsers

Looking at the example here: https://github.com/TypeFox/monaco-languageclient/blob/master/example/src/client.ts I got the impression that this package is meant to be consumed in the browser. However when I try the above sample (instead of typescript I'm just using js), there is an error because vscode-jsonrpc (used by this module) seems to require the net module which is obviously not available for browsers.

Is this expected? Should I just polyfill the net module?

ERROR in ./node_modules/vscode-jsonrpc/lib/pipeSupport.js
Module not found: Error: Can't resolve 'net' in '/Users/balazs.edes/code/studio-prototype-bitbucket/node_modules/vscode-jsonrpc/lib'
 @ ./node_modules/vscode-jsonrpc/lib/pipeSupport.js 10:12-26
 @ ./node_modules/vscode-jsonrpc/lib/main.js
 @ ./node_modules/vscode-ws-jsonrpc/lib/index.js
 @ ./src/components/TempEditorScreen/connectWithLanguageServer.js
 @ ./src/components/TempEditorScreen/index.js
 @ ./src/components/App/index.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://localhost:3000 ./src/index.js

ERROR in ./node_modules/vscode-jsonrpc/lib/socketSupport.js
Module not found: Error: Can't resolve 'net' in '/Users/balazs.edes/code/studio-prototype-bitbucket/node_modules/vscode-jsonrpc/lib'
 @ ./node_modules/vscode-jsonrpc/lib/socketSupport.js 7:12-26
 @ ./node_modules/vscode-jsonrpc/lib/main.js
 @ ./node_modules/vscode-ws-jsonrpc/lib/index.js
 @ ./src/components/TempEditorScreen/connectWithLanguageServer.js
 @ ./src/components/TempEditorScreen/index.js
 @ ./src/components/App/index.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://localhost:3000 ./src/index.js

The error happens just after I require listen:

import { listen } from 'vscode-ws-jsonrpc'

Error - this.socket.onMessage is not a function

var initialize = "null";
const socket:rpc.IWebSocket = new WebSocket('ws://localhost:8080/mypath');
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>('onInitialize');
connection.onNotification(notification, (param: any) => {
	initialize=param; // This prints Hello World
});
connection.listen();

When I tried the above code which is in the readme file it gives an error like before

Request textDocument/completion failed with message: this.socket.onMessage is not a function

Invalid state by "Connection got disposed" in vscode-jsonrpc.

I'm using vscode-ws-jsonrpc with Che-Theia.
It gets sporadically connection failures by "Connection got disposed" error from vscode-jsonrpc.

The stack trace is like this.

2020-09-12 07:11:55.100 root ERROR Error: Connection got disposed.
     at Object.dispose (/home/theia/node_modules/vscode-jsonrpc/lib/main.js:904:25)
     at /home/theia/node_modules/vscode-ws-jsonrpc/lib/socket/connection.js:14:41
     at CallbackList.invoke (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:62:39)
     at Emitter.fire (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:121:36)
     at closeHandler (/home/theia/node_modules/vscode-jsonrpc/lib/main.js:240:26)
     at CallbackList.invoke (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:62:39)
     at Emitter.fire (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:121:36)
     at WebSocketMessageReader.fireClose (/home/theia/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
     at WebSocketMessageReader.fireClose (/home/theia/node_modules/vscode-ws-jsonrpc/lib/socket/reader.js:67:19)
     at /home/theia/node_modules/vscode-ws-jsonrpc/lib/socket/reader.js:24:18

I googled and I found a lot of "Connection displosed" issue in VSCode comminity.
So I suspect this is caused by bugs in vscode-ws-jsonrpc.

In the other hands, I suppose this can be avoid by writing a workaround code.
My suggestion is like this. Is it acceptable?

      protected fireClose(): void {
          if (this.state === 'initial') {
              this.events.splice(0, 0, {});
          } else if (this.state === 'listening') {
-              super.fireClose();
+              try {
+                super.fireClose();
+              } catch (e) { console.error(e); /* Ignore as the connection may be disposed. */ }
          }
          this.state = 'closed';
      }

Add layers surrounding websocket send/onmessage

The current infrastructure doesn't play well with ActionCable based websockets (which is the prevalent way to create websockets in Rails >=5), I would like to propose adding a translation layer between send and onmessage, optionally allowing the user to intercept the message and modifying anything necessary before a message is sent/after a message is received.

How to Capture the Messages or data send from the server.

Received message which is neither a response nor a notification message:
{
    "jsonrpc": "2.0",
    "id": "d287385e-8e56-4e98-a0ef-f96bc55aa2b6"
}

I get the output as follows but i need to get the message that received to a variable is there a way to do that. I used the below code to send.

               rpc.listen({
			webSocket,
			onConnection: (rpcConnection: rpc.MessageConnection) => {
				const notification = new rpc.NotificationType<string, string>('hell');
				rpcConnection.listen();
				rpcConnection.sendNotification(notification, 'hii');			
			},	
		});	

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.