Initial commit
This commit is contained in:
commit
a583c17916
56 files changed
+11025
No files matched your search
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <echoion/api.hpp>
|
||||
#include <echoion/api/Database.hpp>
|
||||
#include "MusicManager.hpp"
|
||||
#include "CommandManager.hpp"
|
||||
#include "NetworkClient.hpp"
|
||||
#include "RpcServer.hpp"
|
||||
#include "ConfigLoader.hpp"
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
|
||||
namespace Echoion::Core {
|
||||
|
||||
// Main Core implementation of ICoreInterface
|
||||
class Core : public Api::ICoreInterface {
|
||||
public:
|
||||
Core();
|
||||
~Core() override;
|
||||
|
||||
// ICoreInterface implementation
|
||||
Api::Result<void> initialize(const std::filesystem::path& configPath) override;
|
||||
Api::Result<void> shutdown() override;
|
||||
[[nodiscard]] bool isInitialized() const noexcept override;
|
||||
|
||||
// Playback control
|
||||
Api::Result<void> play(const Api::TrackInfo& track) override;
|
||||
Api::Result<void> pause() override;
|
||||
Api::Result<void> resume() override;
|
||||
Api::Result<void> stop() override;
|
||||
Api::Result<void> skip(uint32_t count) override;
|
||||
Api::Result<void> seek(std::chrono::milliseconds position) override;
|
||||
Api::Result<void> setVolume(float volume) override;
|
||||
|
||||
// Queue management
|
||||
Api::Result<uint64_t> queueTrack(const Api::TrackInfo& track, uint64_t clientId) override;
|
||||
Api::Result<void> removeFromQueue(uint64_t queueId) override;
|
||||
Api::Result<void> clearQueue() override;
|
||||
[[nodiscard]] Api::Result<std::vector<Api::QueueEntry>> getQueue() const override;
|
||||
Api::Result<void> moveInQueue(uint64_t queueId, uint32_t newPosition) override;
|
||||
|
||||
// Track info
|
||||
[[nodiscard]] Api::Result<std::optional<Api::QueueEntry>> getCurrentTrack() const override;
|
||||
[[nodiscard]] Api::Result<Api::PlaybackState> getPlaybackState() const override;
|
||||
|
||||
// Playlist
|
||||
Api::Result<void> loadPlaylist(const std::string& playlistId, uint64_t clientId) override;
|
||||
[[nodiscard]] Api::Result<std::vector<Api::PlaylistInfo>> getPlaylists() const override;
|
||||
|
||||
// Configuration
|
||||
Api::Result<void> updateConfig(const Api::AppConfig& config) override;
|
||||
[[nodiscard]] Api::Result<Api::AppConfig> getConfig() const override;
|
||||
// Reload config from disk (stored path from initialize)
|
||||
Api::Result<void> reloadConfig();
|
||||
|
||||
// Hot reload
|
||||
Api::Result<Api::HotReloadState> prepareForHotReload() override;
|
||||
Api::Result<void> 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<void> 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> networkClient_;
|
||||
std::shared_ptr<MusicManager> musicManager_;
|
||||
std::unique_ptr<CommandManager> 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<bool> initialized_{false};
|
||||
|
||||
// Event callbacks
|
||||
std::vector<Api::EventCallback> eventCallbacks_;
|
||||
mutable std::mutex eventMutex_;
|
||||
|
||||
// Admin tracking
|
||||
std::vector<uint64_t> adminClients_;
|
||||
mutable std::mutex adminMutex_;
|
||||
|
||||
// Database for persistence
|
||||
std::shared_ptr<Api::Database> database_;
|
||||
|
||||
// RPC server for Desktop/API clients
|
||||
std::shared_ptr<RpcServer> rpcServer_;
|
||||
};
|
||||
|
||||
} // namespace Echoion::Core
|
||||
Reference in new issue
Block a user