Task 4.4: Update WebSocket API Endpoints to use key identifier
- Updated src/server/api/websocket.py docstrings to document key as primary series identifier - Updated src/server/models/websocket.py with detailed docstrings explaining key and folder fields in message payloads - Updated src/server/services/websocket_service.py broadcast method docstrings to document key field usage - Added WebSocket message example with key in infrastructure.md - All 83 WebSocket tests pass - Task 4.4 marked as complete in instructions.md
This commit is contained in:
@@ -2,6 +2,14 @@
|
||||
|
||||
This module provides WebSocket endpoints for clients to connect and receive
|
||||
real-time updates about downloads, queue status, and system events.
|
||||
|
||||
Series Identifier Convention:
|
||||
- `key`: Primary identifier for series (provider-assigned, URL-safe)
|
||||
e.g., "attack-on-titan"
|
||||
- `folder`: Display metadata only (e.g., "Attack on Titan (2013)")
|
||||
|
||||
All series-related WebSocket events include `key` as the primary identifier
|
||||
in their data payload. The `folder` field is optional for display purposes.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -58,19 +66,25 @@ async def websocket_endpoint(
|
||||
}
|
||||
```
|
||||
|
||||
Server message format:
|
||||
Server message format (series-related events include 'key' identifier):
|
||||
```json
|
||||
{
|
||||
"type": "download_progress",
|
||||
"timestamp": "2025-10-17T10:30:00.000Z",
|
||||
"data": {
|
||||
"download_id": "abc123",
|
||||
"key": "attack-on-titan",
|
||||
"folder": "Attack on Titan (2013)",
|
||||
"percent": 45.2,
|
||||
"speed_mbps": 2.5,
|
||||
"eta_seconds": 180
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note:
|
||||
- `key` is the primary series identifier (provider-assigned, URL-safe)
|
||||
- `folder` is optional display metadata
|
||||
"""
|
||||
connection_id = str(uuid.uuid4())
|
||||
user_id: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user