Add WebRTC support and remove deviceId from apis

This commit is contained in:
x0gp
2026-07-15 00:57:36 +04:00
parent 7a7913d2ee
commit c25e0bc581
11 changed files with 1428 additions and 17 deletions
+3 -1
View File
@@ -47,6 +47,7 @@ type Car struct {
ID string
DriverID string // session id
DriverName string
DeviceID *int // internal mapping to physical ESP32 device ID
X, Y float64
Heading float64 // radians
Speed float64 // m/s
@@ -169,7 +170,7 @@ func (e *Engine) SetPhase(p RacePhase) { e.phase.Store(int32(p)) }
// AddCar registers a car and returns it. Returns an error if the driver
// already has a car or the max car count is reached.
func (e *Engine) AddCar(driverID, driverName string, slot int) (*Car, error) {
func (e *Engine) AddCar(driverID, driverName string, slot int, deviceID *int) (*Car, error) {
e.mu.Lock()
defer e.mu.Unlock()
@@ -185,6 +186,7 @@ func (e *Engine) AddCar(driverID, driverName string, slot int) (*Car, error) {
ID: id,
DriverID: driverID,
DriverName: driverName,
DeviceID: deviceID,
// Spread cars along start grid (x = 0, y = slot * 0.4 m).
Y: float64(slot) * 0.4,
}