Replace eventbus/EventBus.hpp (the Api::EventBus wrapper, GlobalEventBus singleton, SubscriptionToken, and the unused ECHOION_PUBLISH/SUBSCRIBE macros) with eventbus/Events.hpp — just the Events:: structs. The bus is now Void::EventBus::EventBus, owned by Core. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
201 lines
3.7 KiB
C++
201 lines
3.7 KiB
C++
#pragma once
|
|
|
|
// Domain event types published on the application event bus. The bus itself
|
|
// is Void::EventBus::EventBus (owned by Core); there is no echoion wrapper.
|
|
|
|
#include "ConfigTypes.hpp"
|
|
#include "PluginTypes.hpp"
|
|
#include "TrackTypes.hpp"
|
|
#include "Types.hpp"
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace Echoion::Api::Events
|
|
{
|
|
|
|
// Playback events
|
|
struct PlaybackStarted {
|
|
TrackInfo track;
|
|
uint64_t clientId;
|
|
std::chrono::milliseconds position;
|
|
};
|
|
|
|
struct PlaybackPaused {
|
|
TrackInfo track;
|
|
std::chrono::milliseconds position;
|
|
};
|
|
|
|
struct PlaybackResumed {
|
|
TrackInfo track;
|
|
std::chrono::milliseconds position;
|
|
};
|
|
|
|
struct PlaybackStopped {
|
|
std::optional<TrackInfo> lastTrack;
|
|
std::chrono::milliseconds finalPosition;
|
|
};
|
|
|
|
struct PlaybackPositionChanged {
|
|
TrackInfo track;
|
|
std::chrono::milliseconds position;
|
|
std::chrono::milliseconds duration;
|
|
float progressPercent; // 0.0 - 100.0
|
|
};
|
|
|
|
struct TrackFinished {
|
|
TrackInfo track;
|
|
bool autoSkipped;
|
|
std::chrono::milliseconds finalPosition;
|
|
};
|
|
|
|
struct VolumeChanged {
|
|
float oldVolume;
|
|
float newVolume;
|
|
uint64_t changedByClientId;
|
|
};
|
|
|
|
struct ShuffleChanged {
|
|
bool enabled;
|
|
uint64_t changedByClientId;
|
|
};
|
|
|
|
struct RepeatChanged {
|
|
bool enabled;
|
|
uint64_t changedByClientId;
|
|
};
|
|
|
|
// Queue events
|
|
struct TrackQueued {
|
|
TrackInfo track;
|
|
uint64_t queueId;
|
|
uint64_t addedByClientId;
|
|
uint32_t position;
|
|
uint32_t queueLength;
|
|
};
|
|
|
|
struct TrackRemoved {
|
|
TrackInfo track;
|
|
uint64_t queueId;
|
|
uint64_t removedByClientId;
|
|
uint32_t queueLength;
|
|
};
|
|
|
|
struct QueueCleared {
|
|
uint64_t clearedByClientId;
|
|
uint32_t previousLength;
|
|
};
|
|
|
|
struct QueueShuffled {
|
|
uint64_t triggeredByClientId;
|
|
};
|
|
|
|
struct QueueReordered {
|
|
uint64_t queueId;
|
|
uint32_t oldPosition;
|
|
uint32_t newPosition;
|
|
uint64_t changedByClientId;
|
|
};
|
|
|
|
// Playlist events
|
|
struct PlaylistLoadStarted {
|
|
std::string playlistId;
|
|
uint64_t requestedByClientId;
|
|
uint64_t databasePlaylistId;
|
|
};
|
|
|
|
struct PlaylistTrackLoaded {
|
|
std::string playlistId;
|
|
TrackInfo track;
|
|
uint32_t loadedCount;
|
|
uint32_t totalCount;
|
|
uint64_t databasePlaylistId;
|
|
};
|
|
|
|
struct PlaylistLoadCompleted {
|
|
std::string playlistId;
|
|
uint32_t totalTracksLoaded;
|
|
bool success;
|
|
std::optional<std::string> error;
|
|
};
|
|
|
|
// Subscription events
|
|
struct UserSubscribed {
|
|
std::string uid;
|
|
std::string nickname;
|
|
uint64_t clientId;
|
|
};
|
|
|
|
struct UserUnsubscribed {
|
|
std::string uid;
|
|
std::string nickname;
|
|
uint64_t clientId;
|
|
};
|
|
|
|
// Connection events
|
|
struct ClientConnected {
|
|
ClientInfo client;
|
|
};
|
|
|
|
struct ClientDisconnected {
|
|
uint64_t clientId;
|
|
std::string reason;
|
|
};
|
|
|
|
struct ChannelChanged {
|
|
uint64_t clientId;
|
|
uint64_t oldChannelId;
|
|
uint64_t newChannelId;
|
|
};
|
|
|
|
// Error events
|
|
struct PlaybackError {
|
|
ErrorCode code;
|
|
std::string message;
|
|
std::optional<TrackInfo> track;
|
|
};
|
|
|
|
struct NetworkError {
|
|
std::string url;
|
|
ErrorCode code;
|
|
std::string message;
|
|
};
|
|
|
|
// Configuration events
|
|
struct ConfigReloaded {
|
|
BotConfig newConfig;
|
|
};
|
|
|
|
struct ConfigChanged {
|
|
std::string key;
|
|
std::string oldValue;
|
|
std::string newValue;
|
|
};
|
|
|
|
// Cache events
|
|
struct CacheHit {
|
|
std::string key;
|
|
std::string type;
|
|
};
|
|
|
|
struct CacheMiss {
|
|
std::string key;
|
|
std::string type;
|
|
};
|
|
|
|
struct CacheEvicted {
|
|
std::string key;
|
|
std::string reason;
|
|
};
|
|
|
|
// Database persistence events (for audit/logging)
|
|
struct DatabasePersisted {
|
|
std::string entityType; // "queue", "playback", ...
|
|
std::string operation; // "insert", "update", "delete"
|
|
bool success;
|
|
std::optional<std::string> error;
|
|
};
|
|
|
|
} // namespace Echoion::Api::Events
|