@shinka-rpc/web-socket
v0.0.2
Published
Symmetric RPC bus. [Documentation is here](https://shinka-rpc-js.readthedocs.io/latest/transports/web-socket/)
Downloads
3
Maintainers
Readme
@shinka-rpc/web-socket
Symmetric RPC bus. Documentation is here
This package implements the transport implementation of @shinka-rpc/core for WebSocket
Usage
client case
import { ClientBus, type FactoryClient } from "@shinka-rpc/core";
import { WebSocketFactoryData } from "@shinka-rpc/web-socket";
import serializer from "@shinka-rpc/serializer-json"; // for example
const factory: FactoryClient<ClientBus> = (bus) => {
const socket = new WebSocket(process.env.WEBSOCKET_URL!);
// Here you are able to do everything with `socket`. For example,
// switch it to binary mode
return WebSocketFactoryData(socket, bus);
};
export const bus = new ClientBus({ factory, serializer });
// You are able to start / stop the bus where you need it
bus.start();API Reference: WebSocketFactoryData
- Required instance:
WebSocket - Required bus:
ClientBus
