BREAKING CHANGE: Documentation URLs have changed New structure: - user/ - End-user documentation (device setup, sync guides, frontend) - developer/ - Developer documentation (API reference, protocols, specs) - operations/ - Operations documentation (deployment, troubleshooting) - contributing/ - Contribution guides Changes: - Created portal INDEX.md files for each audience section - Moved device guides to user/devices/ (kobo-setup.md, koreader-setup.md) - Moved API docs to developer/ (api-reference.md, collections-api.md) - Moved sync guide to user/sync-guide.md - Moved troubleshooting to operations/troubleshooting.md - Moved all split API docs to developer/api/ - Renamed protocol files (kobo-protocol.md, koreader-protocol.md) - Added placeholder user guides (frontend, user-areas, settings, admin) - Updated all internal links to new paths - Updated Go code (http_handler.go, navigation.go) for new paths - Updated main INDEX.md for audience-based navigation Benefits: - Clear separation of user and developer documentation - Scalable structure for future user guide expansion - Better organization and discoverability - Audience-specific landing pages Related to DOCS_IMPLEMENTATION_PLAN.md Phase 2 completion
1.8 KiB
1.8 KiB
WebSocket Protocol
Real-time sync events broadcast to connected clients.
Connect to WebSocket
Endpoint: WS /ws/sync?token=<token>
Connection Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | JWT authentication token |
Example Connection
const ws = new WebSocket('wss://bookhoard.com/ws/sync?token=eyJhbG...');
Message Format
All messages are JSON objects with a type field.
Client → Server Messages
Ping (Heartbeat)
{
"type": "ping"
}
Keep connection alive. Server responds with pong.
Server → Client Messages
Progress Update
{
"type": "progress_update",
"timestamp": "2026-01-31T10:00:00Z",
"data": {
"book_id": "uuid",
"progress": {
"percentage": 0.45678,
"epubcfi": "epubcfi(/6/4/2:15)",
"chapter": 3
},
"annotations": {}
},
"source_device": {
"id": "device-uuid",
"name": "My Kobo",
"type": "kobo"
}
}
Broadcast when any device updates reading progress.
Conflict Detected
{
"type": "conflict",
"timestamp": "2026-01-31T10:00:00Z",
"data": {
"book_id": "uuid",
"conflict_id": "uuid",
"conflict_type": "progress"
}
}
Broadcast when a sync conflict is detected.
Pong
{
"type": "pong"
}
Server response to client ping.
Connection Management
- Heartbeat: Send
pingevery 30 seconds - Reconnect: Use exponential backoff if connection drops
- Authentication: Token must be valid for connection
- Rate Limits: 60 messages/minute per connection
Error Handling
{
"type": "error",
"message": "Invalid token",
"code": "AUTH_FAILED"
}