#pragma once #include #include #include "MusicManager.hpp" #include "CommandManager.hpp" #include "NetworkClient.hpp" #include "RpcServer.hpp" #include "ConfigLoader.hpp" #include #include #include namespace Echoion::Core { // Main Core implementation of ICoreInterface class Core : public Api::ICoreInterface { public: Core(); ~Core() override; // ICoreInterface implementation Api::Result initialize(const std::filesystem::path& configPath) override; Api::Result shutdown() override; [[nodiscard]] bool isInitialized() const noexcept override; // Playback control Api::Result play(const Api::TrackInfo& track) override; Api::Result pause() override; Api::Result resume() override; Api::Result stop() override; Api::Result skip(uint32_t count) override; Api::Result seek(std::chrono::milliseconds position) override; Api::Result setVolume(float volume) override; // Queue management Api::Result queueTrack(const Api::TrackInfo& track, uint64_t clientId) override; Api::Result removeFromQueue(uint64_t queueId) override; Api::Result clearQueue() override; [[nodiscard]] Api::Result> getQueue() const override; Api::Result moveInQueue(uint64_t queueId, uint32_t newPosition) override; // Track info [[nodiscard]] Api::Result> getCurrentTrack() const override; [[nodiscard]] Api::Result getPlaybackState() const override; // Playlist Api::Result loadPlaylist(const std::string& playlistId, uint64_t clientId) override; [[nodiscard]] Api::Result> getPlaylists() const override; // Configuration Api::Result updateConfig(const Api::AppConfig& config) override; [[nodiscard]] Api::Result getConfig() const override; // Reload config from disk (stored path from initialize) Api::Result reloadConfig(); // Hot reload Api::Result prepareForHotReload() override; Api::Result restoreAfterHotReload(const Api::HotReloadState& state) override; // Event handling void registerEventCallback(const Api::EventCallback& callback) override; void unregisterEventCallback(const Api::EventCallback& callback) override; // Plugin event processing Api::Result onPluginEvent(const Api::PluginEvent& event) override; // Status [[nodiscard]] std::string getVersion() const override; [[nodiscard]] std::chrono::system_clock::time_point getUptime() const override; // Additional methods for plugin integration void setPluginInterface(Api::PluginInterfacePtr pluginInterface) override; void setAudioDataCallback(const MusicManager::AudioDataCallback& callback); void triggerAutoConnect() override; private: void onMusicEvent(const Api::PluginEvent& event); void broadcastEvent(const Api::PluginEvent& event); [[nodiscard]] bool isAdmin(uint64_t clientId) const; void updateWhisperList(); void setupRpcHandlers(); // Components std::shared_ptr networkClient_; std::shared_ptr musicManager_; std::unique_ptr commandManager_; Api::PluginInterfacePtr pluginInterface_; // State Api::AppConfig config_; // Config loaded internally std::filesystem::path configPath_; // Path to config file for reload std::chrono::system_clock::time_point startTime_; std::atomic initialized_{false}; // Event callbacks std::vector eventCallbacks_; mutable std::mutex eventMutex_; // Admin tracking std::vector adminClients_; mutable std::mutex adminMutex_; // Database for persistence std::shared_ptr database_; // RPC server for Desktop/API clients std::shared_ptr rpcServer_; }; } // namespace Echoion::Core