diff --git a/server/server.js b/server/server.js index e01e84a..90cbe67 100644 --- a/server/server.js +++ b/server/server.js @@ -249,20 +249,14 @@ wss.on('connection', (ws) => { const turtle = turtles.get(turtleID); if (turtle) { - // Check for state change commands + // All commands are state changes — server controls all turtle movement if (data.command === 'set_state' || data.command === 'setState') { const stateName = data.param?.state || data.param; const stateData = data.param?.data || {}; turtle.setState(stateName, stateData); console.log(`✅ State set for turtle ${turtleID}: ${stateName}`); } else { - // Legacy command - queue for webbridge polling - turtle.pendingLegacyCommands.push({ - command: data.command, - param: data.param, - timestamp: Date.now() - }); - console.log(`✅ Command queued for turtle ${turtleID}: ${data.command}`, data.param ? `(param: ${JSON.stringify(data.param)})` : ''); + console.log(`⚠️ Unrecognized command from web client: ${data.command} — use state machine or server-side action routes`); } } else { console.log(`❌ Turtle ${turtleID} not found`); @@ -524,22 +518,17 @@ app.post('/api/turtle/:id/command', (req, res) => { const turtle = turtles.get(turtleID); if (turtle) { - // Check for state change commands + // All commands are state changes — server controls all turtle movement if (command === 'set_state' || command === 'setState') { const stateName = param?.state || param; const stateData = param?.data || {}; turtle.setState(stateName, stateData); console.log(`📤 State set for turtle ${turtleID}: ${stateName}`); + res.json({ success: true }); } else { - // Legacy command - queue for webbridge - turtle.pendingLegacyCommands.push({ - command, - param, - timestamp: Date.now() - }); - console.log(`📤 Command queued for turtle ${turtleID}:`, command); + console.log(`⚠️ Legacy command rejected for turtle ${turtleID}: ${command} — use state machine or server-side action routes`); + res.status(400).json({ error: 'Legacy commands are no longer supported. Use state machine or action routes.' }); } - res.json({ success: true }); } else { res.status(404).json({ error: 'Turtle not found' }); }