-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support nodejs IPC endpoint (uses named pipes on Windows, and UNIX domain sockets otherwise) #44
Comments
For your use case, this library supports WebSocket and HTTP. When talking to browsers it is best to use a WebSocket. NodeJS runs just about anywhere and has no dependencies. Here's an implementation which appears to support raw sockets/streams: https://github.com/Microsoft/vscode-languageserver-node/tree/master/jsonrpc So you could problably do it like this: |
Yes, language server in vscode are using stdio pipe to communicate but its not suitable in my use case since there is a scenario where bunch of simulated firmware talk to the bridge. Thats why I think unix domain socket is good alternative (because it can handle duplex communication more) since docker daemon communicate via this layer to. (I also found out that stdio pipe has buffer limitation so I can't send a data that's to large). There is other reason that I consider unix socket because the simulated firmware are written in different language, writing it to send data in unix socket is easier than writing it to send data in stdio pipe (need to switch between stdin and stdout). I actually plan to implement the bridge using vs-jsonrpcstream (in C#) |or| jayson-rpc (in Nodejs) [still not decided] and make the browser (web browser) and the simulated firmware both as a rpc-client. However, since I found this library, I wonder if in the future I can just simplified by making the browser as rpc-server and the bridge is just like a bridge with same dependency (jsonrpc-bidirectional). And maybe add some auth feature in the bridge. About jayson-rpc, its json-rpc library with features almost same as jsonrpc-bidirectional but there are missing feature to create jsonrpc-server in the web browser. |
You can still use jsonrpc-bidirectional as I have explained above, replacing the Microsoft thing with what you found. Additionally, you can write your authentication and authorization layers as jsonrpc-bidirectional plugins, on both the server and the browser. In short, jsonrpc-bidirectional would be the centerpiece of your architecture and you would add all your server logic in it, allowing you to have a JSONRPC.Server in the browser. jayson-rpc would only be an adapter in the same application (proxying RPCs from that firmware thing). |
Look at the authorization plugin in the tests directory for a login session example. Usage is in the tests. If you want to write it from scratch see the plugins in src. |
Any plan to support net.Socket class?
I have some use case when I need to create some bridge that passes JSON-RPC data from Unix Domain Socket into WebSocket. Something like
The text was updated successfully, but these errors were encountered: