mirror of
https://github.com/IS1DI/x0gp.git
synced 2026-07-16 20:47:55 +00:00
feat(server): integrate UDP video service and normalize database schema
- Implement UDPVideoService to stream MJPEG video frames from ESP32s via UDP and send control commands. - Normalize race database schema: - Remove redundant driver_ids array from races table (migration 011). - Move per-driver outcomes (total_time_ms, best_lap_ms, position) to race_drivers table (migration 012). - Add device_id column to lobby_drivers to link active physical devices (migration 013). - Update WebSocket handler to pass lobbySvc, driversSvc, and videoSvc for driver identity tracking, syncing in-memory driver metadata, and forwarding WS controls to physical cars. - Add CORS middleware to HTTP routes. - Regenerate Swagger documentation.
This commit is contained in:
@@ -85,7 +85,7 @@ func racesListHandler(svc *races.Service) http.HandlerFunc {
|
||||
writeJSON(w, http.StatusOK, transport.RaceListResponse{
|
||||
Items: items,
|
||||
NextCursor: res.NextCursor,
|
||||
Count: len(items),
|
||||
Count: res.TotalCount,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -382,10 +382,15 @@ func racePlansListHandler(svc *races.Service) http.HandlerFunc {
|
||||
last := out[len(out)-1]
|
||||
nextCur = races.Cursor{Ms: last.StartAtMs, ID: last.ID}.Encode()
|
||||
}
|
||||
totalCount, err := svc.CountPlans(r.Context())
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal", err.Error())
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, transport.RacePlanListResponse{
|
||||
Items: out,
|
||||
NextCursor: nextCur,
|
||||
Count: len(out),
|
||||
Count: totalCount,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user