Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielgrant/grpc-bus-websocket-proxy-client
Connect to any GRPC service from a browser via a WebSocket Proxy Server
https://github.com/gabrielgrant/grpc-bus-websocket-proxy-client
Last synced: 5 days ago
JSON representation
Connect to any GRPC service from a browser via a WebSocket Proxy Server
- Host: GitHub
- URL: https://github.com/gabrielgrant/grpc-bus-websocket-proxy-client
- Owner: gabrielgrant
- Created: 2017-01-06T20:49:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-12T18:12:12.000Z (over 6 years ago)
- Last Synced: 2024-10-30T18:19:01.684Z (14 days ago)
- Language: JavaScript
- Homepage:
- Size: 279 KB
- Stars: 16
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
GRPC-Bus WebSocket Proxy Client
This client library connects a browser's JavaScript context to standard GRPC service(s) via a WebSocket Proxy Server with full support for bi-directional streaming (ie both [server-initiated](https://github.com/gabrielgrant/grpc-bus-websocket-proxy-client/blob/master/demo/demo.js#L23) or [client-initiated](https://github.com/gabrielgrant/grpc-bus-websocket-proxy-client/blob/master/demo/demo.js#L23))
Install
```sh
npm install grpc-bus-websocket-client
```You'll also need to install and run a [GRPC Bus WebSocket Proxy Server](http://github.com/gabrielgrant/grpc-bus-websocket-proxy-server)
Usage
```
new GBC(, , )
```Example
```javascript
var GBC = require("grpc-bus-websocket-client");new GBC("ws://localhost:8080/", 'helloworld.proto', {helloworld: {Greeter: 'localhost:50051'}})
.connect()
.then(function(gbc) {
gbc.services.helloworld.Greeter.sayHello({name: 'Gabriel'}, function(err, res){
console.log(res);
}); // --> Hello Gabriel
});
```For more complex proto defs that import other `.proto` files, the proto
def tree should be compiled into a single JSON file using the `pbjs`
command line utility included with the `protobufjs` lib from NPM.After installing `grpc-bus-websocket-client`, run the
compilation from your project directory:```
./node_modules/protobufjs/bin/pbjs helloworld.proto > helloworld.proto.json
```