Closed DrSensor closed 6 years ago
For the HTTP and WebSocket transports, the endpoint is just an http URL (prefixed with ws:// instead of http:// for websockets). WebSockets always run over HTTP at a specific URL pathname. For other transports the endpoint doesn't mean anything, or is just a way to categorize functions into some kind of namespaces.
You can have /
as an URL path or /api
or anything you need.
See the HTTP server part where it decides that /api goes to JSONRPC.
To keep things simple, register just one endpoint at specific URL pathname, and use that as convention everywhere.
Hi, after reading Bidirectional JSON-RPC over WebSocket I had little confusion. Is it possible to serve JSON-RPC from nodejs without specifying endpoint functions? e.g no
jsonrpcServer.registerEndpoint(new TestEndpoint())
I bump into a use case that the server (set as JSON-RPC client) doesn't know anything about the endpoint function (
ping(str)
,add(numA, numB)
, etc) that the JSON-RPC server (run on Web Browser) has. For example, given this CLI:In here
rpc-call-to
act as a websocket server and also rpc-client whiledemo/index.html
containTestEndpoint
specified by the end-user.