style: Remove unused sendCommand function from turtleStore
This commit is contained in:
@@ -216,35 +216,6 @@ export const useTurtleStore = create((set, get) => ({
|
||||
set({ worldBlocks: Array.from(blockMap.values()) });
|
||||
},
|
||||
|
||||
sendCommand: async (turtleId, command, param = null) => {
|
||||
const { ws } = get();
|
||||
|
||||
console.log(`🎮 Sending command to turtle ${turtleId}: ${command}`, param ? `(param: ${JSON.stringify(param)})` : '');
|
||||
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(JSON.stringify({
|
||||
type: 'command',
|
||||
turtleID: turtleId,
|
||||
command,
|
||||
param
|
||||
}));
|
||||
console.log(' ✅ Sent via WebSocket');
|
||||
} else {
|
||||
// Fallback to REST API
|
||||
console.log(' ⚠️ WebSocket not connected, using REST API fallback');
|
||||
try {
|
||||
await fetch(`${API_URL}/turtle/${turtleId}/command`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ command, param })
|
||||
});
|
||||
console.log(' ✅ Sent via REST API');
|
||||
} catch (error) {
|
||||
console.error(' ❌ Error sending command:', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Set turtle state machine state via REST API
|
||||
setTurtleState: async (turtleId, stateName, stateData = {}) => {
|
||||
console.log(`🔄 Setting state for turtle ${turtleId}: ${stateName}`, stateData);
|
||||
|
||||
Reference in New Issue
Block a user