Metadata-Version: 2.4
Name: kasper-socket
Version: 0.1.0
Summary: Rooms, broadcast, and presence for WebSocket apps behind a small async API.
Author-email: Kunta Mallik Raj <kuntamallikraj@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/KuntaMallikRaj
Keywords: websocket,rooms,broadcast,presence,realtime,socket
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: AsyncIO
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: redis
Requires-Dist: redis>=4.2; extra == "redis"
Dynamic: license-file

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

```bash
pip install kasper-socket
```

```python
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.
