Rooms, broadcast, and presence for WebSocket apps behind a small async API.
Project description
kasper-socket
Rooms, broadcast, and presence for WebSocket apps - behind a small async API. Framework-agnostic: works with FastAPI / Starlette / the websockets library. Any object with an async send(str) is a valid socket.
pip install kasper-socket
from kasper_socket import SocketHub
hub = SocketHub()
conn = await hub.connect(ws, user_id="u1", rooms=["case-42"])
await hub.broadcast("case-42", {"type": "edit", "field": "status"})
await hub.presence("case-42") # -> ["u1", "u2"]
await hub.disconnect(conn)
@hub.on("edit")
async def handle(conn, msg):
...
await hub.dispatch(conn, {"type": "edit", "field": "status"})
Notes
- Single node broadcast is an in-process room lookup.
- Presence is tracked per room and emitted as a sorted member list.
- A Redis pub/sub backend (for multi-node broadcast across server instances) is the planned
[redis]extra.
MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kasper_socket-0.1.0.tar.gz
(4.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kasper_socket-0.1.0.tar.gz.
File metadata
- Download URL: kasper_socket-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67acd318940ef7b414b40e80d80e00a34bade288097691bcc435be1e294699ec
|
|
| MD5 |
ec1c2ff1e5f3b89f75a33870f0a01f20
|
|
| BLAKE2b-256 |
e4579a2727935e884e0bf1c7afb5158d17afefbc14e8bcd7c5de70adc27e90fa
|
File details
Details for the file kasper_socket-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kasper_socket-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b42495c350db156242cf1b809797abb4cea4b2c7bacbc52d38624c903a60787
|
|
| MD5 |
2904775dc5910cded6952223e6c36422
|
|
| BLAKE2b-256 |
22a5718475e6203938cb0bc91442a38d9b1e06314aa7ca98048e76e5742aa58f
|