Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 1.46 KB

File metadata and controls

44 lines (28 loc) · 1.46 KB

@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.