uber-archive / multitransport-jsonrpc

JSON-RPC Client (Node.js & Browser) and Server (Node.js) aim at "natural looking" server and client code.
116 stars 22 forks source link

any example showing browser usage of http transport? #71

Open darrencruse opened 9 years ago

darrencruse commented 9 years ago

Hi this package looks pretty nice this was really just a question I wasn't sure about:

I notice the express middleware for the server side, and I snooped in the test dir, but is there a browser (client) example anywhere?

(noting e.g. the project description says "JSON-RPC Client (Node.js & Browser)")

In particular, I was unclear if browserify could/should be used, or maybe could/would I use some other json-rpc client package for the browser side? (since am I right the client transports look like they assume node?)

(as an aside I'd also be interested in websocket usage - but that's not supported correct)

dfellis commented 9 years ago

So long ago there was a native web client and the node support was bolted on with the node-xmlhttprequest library. This caused a significant performance penalty for node, but once browserify became stable, we saw that its fake http lib wrapper around the real XMLHttpRequest caused a minimal perf penalty for the browser, and then rewrote the code to get the performance boost on the server.

And there is no websocket transport right now. Nothing really stopping it, but we haven't had any use for one. We're open to pull requests, though! (And the architecture is modular enough that you could keep it private and not even fork multitransport-jsonrpc if that's your preference, as well.)