This is not well maintained
This is not traditional RPC, but it is like it
yarn add @ch1/rpc-web-socket
This library has an external optional run time dependency for the server side portion, which leverages the excellent ws library.
The dependency is optional in that this library will work with anything that
We do include
ws as a
devDependency since we use it for testing the
library end to end.
Slightly easier API than in the raw
Client JS Script (using the function foo on the server)
Server JS (sharing the function foo to the client)
Due to the nature of state that could exist on client/server, this library takes the approach of terminating itself in the event of catastrophic failure.
- Individual functions that fail are left up to the user to handle
- Connection failures will result in the destruction of the object
- Pending async requests will have their error handlers triggered
best practice is to add an error listener:
Web Socket Connection Handling
This library attempts to automatically handle all connection errors and fail fast where possible. This includes a server side "ping pong" to detect "unplug" events.
Reconnection Is Left Up To The User of The Library,
Presumably the client will be responsible for the reconnection.
create function will provide an
RPCSocketConfig object looks like:
RPC<RemoteType> object is described in the documentation for @ch1/rpc