diff --git a/server/server.js b/server/server.js index d6c2c88..f11850d 100644 --- a/server/server.js +++ b/server/server.js @@ -114,7 +114,7 @@ function getOrCreateTurtle(turtleID) { // Forward eval commands to webbridge via pending command queue turtle.on('sendCommand', (command) => { // Queue eval command for webbridge to poll - turtle.pendingLegacyCommands.push({ + turtle.pendingCommands.push({ ...command, timestamp: Date.now(), }); @@ -341,15 +341,15 @@ app.get('/api/turtle/:id/commands', (req, res) => { if (turtle) { // Combine eval commands + legacy commands - const commands = turtle.pendingLegacyCommands || []; + const commands = turtle.pendingCommands || []; // Clean up old commands (older than 30 seconds) const now = Date.now(); - turtle.pendingLegacyCommands = commands.filter(cmd => (now - cmd.timestamp) < 30000); + turtle.pendingCommands = commands.filter(cmd => (now - cmd.timestamp) < 30000); - if (turtle.pendingLegacyCommands.length > 0) { - console.log(`📤 Sending ${turtle.pendingLegacyCommands.length} command(s) to turtle ${turtleID}`); - turtle.pendingLegacyCommands.forEach(cmd => { + if (turtle.pendingCommands.length > 0) { + console.log(`📤 Sending ${turtle.pendingCommands.length} command(s) to turtle ${turtleID}`); + turtle.pendingCommands.forEach(cmd => { if (cmd.type === 'eval') { console.log(` - EVAL ${(cmd.uuid || '').substring(0, 8)}`); } else { @@ -358,7 +358,7 @@ app.get('/api/turtle/:id/commands', (req, res) => { }); } - res.json({ commands: turtle.pendingLegacyCommands }); + res.json({ commands: turtle.pendingCommands }); } else { res.json({ commands: [] }); } @@ -375,11 +375,11 @@ app.post('/api/turtle/:id/commands/ack', (req, res) => { const turtle = turtles.get(turtleID); if (turtle) { - const clearedCount = (turtle.pendingLegacyCommands || []).length; + const clearedCount = (turtle.pendingCommands || []).length; if (clearedCount > 0) { console.log(`✅ Turtle ${turtleID} acknowledged ${clearedCount} command(s)`); - turtle.pendingLegacyCommands = []; + turtle.pendingCommands = []; } res.json({ success: true, cleared: clearedCount });