# Foxglove WebSocket server
This package provides a server implementation of the [Foxglove WebSocket protocol](https://github.com/foxglove/ws-protocol) with examples. The protocol enables [Foxglove Studio](https://github.com/foxglove/studio) to ingest arbitrary “live” streamed data.
## Installation
```
$ pip install foxglove-websocket
```
## Example servers
This package includes example servers demonstrating how to use JSON and Protobuf data. To install additional dependencies required for the examples, run:
```
$ pip install 'foxglove-websocket[examples]'
```
Run a simple example server that publishes messages on a single `example_msg` topic:
- [JSON server](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/json_server.py) – Uses JSON to encode message data and [JSON Schema](https://json-schema.org/) to describe the message layout.
```
python -m foxglove_websocket.examples.json_server
```
- [Protobuf server](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/protobuf_server.py) – Uses [Protobuf](https://developers.google.com/protocol-buffers) to encode message data.
```
python -m foxglove_websocket.examples.protobuf_server
```
_Note:_ You must exit each server (<kbd>control</kbd> + <kbd>c</kbd>) before starting up another.
To see data from any server, open [Foxglove Studio](https://studio.foxglove.dev?ds=foxglove-websocket&ds.url=ws://localhost:8765/) with a Foxglove WebSocket connection to `ws://localhost:8765/`:
<img width="676" alt="Foxglove Studio displaying data from the example server" src="https://user-images.githubusercontent.com/14237/145260376-ddda98c5-7ed0-4239-9ce4-10778ee8240b.png">
To customize each server for your specifications, copy either server into a separate file like `server.py` and make the desired adjustments to this template. Start up your server from the command line, using `python3 server.py`.
### Multi-threaded usage
The [`threaded_server` example](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/threaded_server/__main__.py) demonstrates how to use the `FoxgloveServer` class in a thread-safe way when interacting with a threaded middleware. Run the server using:
```
python -m foxglove_websocket.examples.threaded_server
```
When connected to the server in Foxglove Studio, use the [Data Source Info](https://foxglove.dev/docs/studio/panels/data-source-info) panel to see channels appearing and disappearing, and a [Plot](https://foxglove.dev/docs/studio/panels/plot) panel to visualize data on each channel.
<img width="869" alt="image" src="https://user-images.githubusercontent.com/14237/154611361-37f87c06-b85f-4117-8bfe-e1bbbc31f7f4.png">
For a more detailed explanation, read the [example's source code](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/threaded_server/__main__.py).
## Development
When developing or maintaining the `foxglove-websocket` package, it is recommended to use [`pipenv`](https://github.com/pypa/pipenv) to manage development dependencies and `virtualenv`.
- `pipenv install --dev` – Create a `virtualenv` and install development dependencies
- `pipenv shell` – Enter the `virtualenv`
Raw data
{
"_id": null,
"home_page": "https://github.com/foxglove/ws-protocol",
"name": "foxglove-websocket",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "foxglove,websocket,robotics,ros,ros2",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/36/63/b747abdcaa1c97f725292920ebb5dc0da04f0e25472a3a3ec6f529093d7a/foxglove-websocket-0.1.2.tar.gz",
"platform": null,
"description": "# Foxglove WebSocket server\n\nThis package provides a server implementation of the [Foxglove WebSocket protocol](https://github.com/foxglove/ws-protocol) with examples. The protocol enables [Foxglove Studio](https://github.com/foxglove/studio) to ingest arbitrary \u201clive\u201d streamed data.\n\n## Installation\n\n```\n$ pip install foxglove-websocket\n```\n\n## Example servers\n\nThis package includes example servers demonstrating how to use JSON and Protobuf data. To install additional dependencies required for the examples, run:\n\n```\n$ pip install 'foxglove-websocket[examples]'\n```\n\nRun a simple example server that publishes messages on a single `example_msg` topic:\n\n- [JSON server](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/json_server.py) \u2013 Uses JSON to encode message data and [JSON Schema](https://json-schema.org/) to describe the message layout.\n\n ```\n python -m foxglove_websocket.examples.json_server\n ```\n\n- [Protobuf server](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/protobuf_server.py) \u2013 Uses [Protobuf](https://developers.google.com/protocol-buffers) to encode message data.\n\n ```\n python -m foxglove_websocket.examples.protobuf_server\n ```\n\n_Note:_ You must exit each server (<kbd>control</kbd> + <kbd>c</kbd>) before starting up another.\n\nTo see data from any server, open [Foxglove Studio](https://studio.foxglove.dev?ds=foxglove-websocket&ds.url=ws://localhost:8765/) with a Foxglove WebSocket connection to `ws://localhost:8765/`:\n\n<img width=\"676\" alt=\"Foxglove Studio displaying data from the example server\" src=\"https://user-images.githubusercontent.com/14237/145260376-ddda98c5-7ed0-4239-9ce4-10778ee8240b.png\">\n\nTo customize each server for your specifications, copy either server into a separate file like `server.py` and make the desired adjustments to this template. Start up your server from the command line, using `python3 server.py`.\n\n### Multi-threaded usage\n\nThe [`threaded_server` example](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/threaded_server/__main__.py) demonstrates how to use the `FoxgloveServer` class in a thread-safe way when interacting with a threaded middleware. Run the server using:\n\n```\npython -m foxglove_websocket.examples.threaded_server\n```\n\nWhen connected to the server in Foxglove Studio, use the [Data Source Info](https://foxglove.dev/docs/studio/panels/data-source-info) panel to see channels appearing and disappearing, and a [Plot](https://foxglove.dev/docs/studio/panels/plot) panel to visualize data on each channel.\n\n<img width=\"869\" alt=\"image\" src=\"https://user-images.githubusercontent.com/14237/154611361-37f87c06-b85f-4117-8bfe-e1bbbc31f7f4.png\">\n\nFor a more detailed explanation, read the [example's source code](https://github.com/foxglove/ws-protocol/blob/main/python/src/foxglove_websocket/examples/threaded_server/__main__.py).\n\n## Development\n\nWhen developing or maintaining the `foxglove-websocket` package, it is recommended to use [`pipenv`](https://github.com/pypa/pipenv) to manage development dependencies and `virtualenv`.\n\n- `pipenv install --dev` \u2013 Create a `virtualenv` and install development dependencies\n- `pipenv shell` \u2013 Enter the `virtualenv`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Foxglove WebSocket server",
"version": "0.1.2",
"project_urls": {
"Foxglove Studio Documentation": "https://foxglove.dev/docs",
"GitHub Issues": "https://github.com/foxglove/ws-protocol/issues",
"Homepage": "https://github.com/foxglove/ws-protocol"
},
"split_keywords": [
"foxglove",
"websocket",
"robotics",
"ros",
"ros2"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0e892ee40e7d287dee8f0fd5f7b5b59b7ee5e663174cbe9ef568a1506dd7e7c5",
"md5": "994e2c4c63936e46c7f3acb342602346",
"sha256": "7a231f90ee1ec08c2f6b302270bf45998cc125fb0b16e170a3ea6d1b8b559d1e"
},
"downloads": -1,
"filename": "foxglove_websocket-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "994e2c4c63936e46c7f3acb342602346",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 13891,
"upload_time": "2023-06-12T17:42:52",
"upload_time_iso_8601": "2023-06-12T17:42:52.996521Z",
"url": "https://files.pythonhosted.org/packages/0e/89/2ee40e7d287dee8f0fd5f7b5b59b7ee5e663174cbe9ef568a1506dd7e7c5/foxglove_websocket-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3663b747abdcaa1c97f725292920ebb5dc0da04f0e25472a3a3ec6f529093d7a",
"md5": "5baab6fabbfabdf6a849e268530087eb",
"sha256": "26bc61e026d9f2b6f0fe34df6a798ce95e453cdce5565b730e0591ac1f52fdcb"
},
"downloads": -1,
"filename": "foxglove-websocket-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "5baab6fabbfabdf6a849e268530087eb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 15798,
"upload_time": "2023-06-12T17:42:54",
"upload_time_iso_8601": "2023-06-12T17:42:54.795060Z",
"url": "https://files.pythonhosted.org/packages/36/63/b747abdcaa1c97f725292920ebb5dc0da04f0e25472a3a3ec6f529093d7a/foxglove-websocket-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-12 17:42:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "foxglove",
"github_project": "ws-protocol",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "foxglove-websocket"
}