#ifndef LICHESS_BOARD_H #define LICHESS_BOARD_H #include #include #include // Callback pour chaque coup reçu typedef void (*MoveCallback)(String from, String to, String san, String fen); typedef void (*GameStateCallback)(String state); // started, finished, etc. class LichessBoard { private: WiFiClientSecure client; String apiToken; String currentGameId; bool streaming; String lastLine; MoveCallback onMoveReceived; GameStateCallback onGameStateChanged; unsigned long lastHeartbeat; const unsigned long heartbeatTimeout = 10000; // 10 secondes // Parse une ligne JSON du stream void parseLine(String line); public: LichessBoard(); // Configuration void setToken(String token); void setMoveCallback(MoveCallback callback); void setGameStateCallback(GameStateCallback callback); // Stream d'une partie spécifique bool streamGame(String gameId); // Stream de vos parties en cours (nécessite token) bool streamMyGames(); // Stream des événements de votre compte bool streamEvents(); // À appeler dans loop() void loop(); // Contrôle void stop(); bool isStreaming(); String getCurrentGameId(); // Récupérer l'état actuel d'une partie (non-stream) bool getGameState(String gameId, String &fen, String &lastMove); }; #endif