@zwoo/dashboard-client
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@zwoo/dashboard-client

A Javascript/Typescript ZRPe dashboard client.

@zwoo/dashboard-client license issues

Quickstart

Install the package via npm/yarn/pnpm

npm i @zwoo/dashboard-client

Usage

import { ProxyClient, Configuration, forGame } from "@zwoo/dashboard-client";

const config = Configuration.withUrl("ws://localhost:9072"); // .fromImportMeta() // .fromEnv()
const socket = new ProxyClient(config);

await socket.connect();

socket.on("open", () => { /* connection opened */});
socket.on("close", () => { /* connection closed */ });
socket.on("error", (e) => { /* a websocket error occurred */ });
socket.on("message", (msg) => { /* received a ZRPe message */ });
socket.on("targetsUpdated", (targets) => {/* the list of listening targets updated */ });

const target = "foo";
await socket.listen(target); // listen to a distributor
await socket.unlisten(target); // stop listening to a distributor

// filtered message handler
socket.on("message", forGame(1, (msg) => { /* received a ZRPe message for game 1 */ }));

If Configuration.fromImportMeta() / Configuration.fromEnv() is used, you must provide:

  • ZRP_DEBUG_PROXY_URL (the url to the zrp proxy)

as environment variables.

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @zwoo/dashboard-client

    Weekly Downloads

    1

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    11.1 kB

    Total Files

    9

    Last publish

    Collaborators

    • zwoo-admin
    • fabiankachlock