@foxglove/ws-protocol-examples

Foxglove WebSocket protocol examples

Usage no npm install needed!

<script type="module">
  import foxgloveWsProtocolExamples from 'https://cdn.skypack.dev/@foxglove/ws-protocol-examples';
</script>

README

Foxglove WebSocket examples

This package provides example server and client implementations of the Foxglove WebSocket protocol. The protocol enables Foxglove Studio to ingest arbitrary “live” streamed data.

To list all possible actions, run the following command:

$ npx @foxglove/ws-protocol-examples@latest --help

Example servers

Run the sysmon example server, which uses JSON-encoded data to transmit system monitoring information like memory and CPU usage:

$ npx @foxglove/ws-protocol-examples@latest sysmon

Run the image-server example server, which uses JSON-encoded data to transmit images:

$ npx @foxglove/ws-protocol-examples@latest image-server

Note: You must exit each server (control + c) before starting up another.

To see data from any server, open Foxglove Studio with a Foxglove WebSocket connection to ws://localhost:8765/:

Foxglove Studio displaying memory and CPU usage from the system monitor example Foxglove Studio displaying images from the image server example

Example client

Run a simple example client that subscribes to messages with the protobuf or json encoding:

$ npx @foxglove/ws-protocol-examples@latest simple-client localhost:8765

Development

This package lives inside a monorepo that uses yarn workspaces, so most commands (other than yarn install) should be prefixed with yarn workspace @foxglove/ws-protocol-examples ....

  • yarn install – Install development dependencies
  • yarn workspace @foxglove/ws-protocol-examples version --patch (or --minor or --major) – Increment the version number and create the appropriate git tag
  • yarn workspace @foxglove/ws-protocol-examples run-example --help – Run the example scripts