0.0.1 • Published 3 months ago

@shinka-rpc/web-socket v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@shinka-rpc/web-socket

Symmetric RPC bus

This package contains a parametrizers of @shinka-rpc/core for WebSocket

Usage

client case

import { ClientBus, type FactoryClient } from "@shinka-rpc/core";
import { WebSocketFactoryData } from "@shinka-rpc/web-socket";

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 to
  // binary mode
  return WebSocketFactoryData(socket, bus);
};

export const bus = new ClientBus({ factory });

// You are able to start / stop the bus where you need it
bus.start();

API Reference: WebSocketFactoryData

  • Required instance: WebSocket
  • Required bus: ClientBus