Migrate core infrastructure to VoidLibrary
This commit is contained in:
1 parent
53801f2b53
commit
2bdb63766d
65 files changed
+16109
-12011
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include "TrackTypes.hpp"
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Echoion::Core
|
||||
{
|
||||
|
||||
using namespace Echoion::Api;
|
||||
|
||||
// State V0 - Initial version (placeholder for testing migration)
|
||||
struct StateV0 {
|
||||
std::vector<std::string> trackIds;
|
||||
float volume = 0.5f;
|
||||
};
|
||||
|
||||
// State V1 - Current version with full playback state
|
||||
struct StateV1 {
|
||||
// Playback state
|
||||
struct PlaybackState {
|
||||
TrackInfo currentTrack;
|
||||
int64_t positionMs = 0; // Use int64 for JSON compatibility
|
||||
bool isPlaying = false;
|
||||
bool isPaused = false;
|
||||
float volume = 0.5f;
|
||||
bool shuffle = false;
|
||||
bool repeat = false;
|
||||
};
|
||||
|
||||
// Queue entry with metadata
|
||||
struct QueueEntryState {
|
||||
TrackInfo track;
|
||||
uint64_t queueId = 0;
|
||||
std::string addedBy;
|
||||
std::string addedAt; // ISO 8601
|
||||
};
|
||||
|
||||
// Session state for RPC clients
|
||||
struct SessionState {
|
||||
uint64_t clientId = 0;
|
||||
std::string authToken;
|
||||
std::string lastActivity; // ISO 8601
|
||||
};
|
||||
|
||||
// Main state
|
||||
PlaybackState playback;
|
||||
bool hasPlayback =
|
||||
false; // Flag to indicate if playback state is valid
|
||||
std::vector<QueueEntryState> queue;
|
||||
std::vector<SessionState> sessions;
|
||||
|
||||
// Version info
|
||||
uint32_t version = 1;
|
||||
std::string savedAt; // ISO 8601
|
||||
};
|
||||
|
||||
} // namespace Echoion::Core
|
||||
|
||||
// StateV0/StateV1 (and the nested PlaybackState/QueueEntryState/SessionState)
|
||||
// are plain reflectable aggregates whose member names are the desired JSON
|
||||
// keys, so Void::Json reflection serializes them with no annotations. The only
|
||||
// non-reflectable member is TrackInfo, which supplies its own
|
||||
// to_json()/from_json() in TrackTypes.hpp.
|
||||
Reference in new issue
Block a user