Own the event bus in Core; inject it into MusicManager
Core holds a Void::EventBus::EventBus (Async), provides it as a service, and runs its 18 event subscriptions against it directly (setupEventBusSubscriptions is no longer const since it now mutates the owned bus). MusicManager gets the bus via setEventBus() and publishes through a small emit<T>() helper (14 former GlobalEventBus publish sites). Delete EventBus.cpp (the singleton definition). Build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d56a6ff01
commit
f7553d10d3
5 files changed
+63
-57
No files matched your search
+15
-15
@@ -1,7 +1,7 @@
|
||||
#include "ConfigManager.hpp"
|
||||
#include "LoggerInterface.hpp"
|
||||
#include "echoion/core/MusicManager.hpp"
|
||||
#include <EventBus.hpp>
|
||||
#include <Events.hpp>
|
||||
#include <algorithm>
|
||||
#include <execution>
|
||||
#include <filesystem>
|
||||
@@ -396,7 +396,7 @@ namespace Echoion::Core
|
||||
ECHOION_LOG_INFO("Playback stopped");
|
||||
|
||||
// Publish playback stopped event
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::PlaybackStopped{
|
||||
emit(Api::Events::PlaybackStopped{
|
||||
.lastTrack = currentTrack_ ? std::optional(currentTrack_->track)
|
||||
: std::nullopt,
|
||||
.finalPosition = playbackPosition_});
|
||||
@@ -493,7 +493,7 @@ namespace Echoion::Core
|
||||
ECHOION_LOG_INFO(std::format("Volume set to {}", volume));
|
||||
|
||||
// Publish volume changed event
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::VolumeChanged{
|
||||
emit(Api::Events::VolumeChanged{
|
||||
.oldVolume = oldVolume,
|
||||
.newVolume = volume,
|
||||
.changedByClientId = 0 // Will be set by caller if available
|
||||
@@ -663,7 +663,7 @@ namespace Echoion::Core
|
||||
ECHOION_LOG_INFO(std::format("Removed track at position {}", position));
|
||||
|
||||
// Publish track removed event
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::TrackRemoved{
|
||||
emit(Api::Events::TrackRemoved{
|
||||
.track = removedTrack.track,
|
||||
.queueId = removedTrack.queueId,
|
||||
.removedByClientId = 0,
|
||||
@@ -687,7 +687,7 @@ namespace Echoion::Core
|
||||
ECHOION_LOG_INFO("Queue cleared");
|
||||
|
||||
// Publish queue cleared event
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::QueueCleared{
|
||||
emit(Api::Events::QueueCleared{
|
||||
.clearedByClientId = 0, .previousLength = previousLength});
|
||||
|
||||
return {};
|
||||
@@ -738,7 +738,7 @@ namespace Echoion::Core
|
||||
ECHOION_LOG_INFO(std::format("Moved track from {} to {}", from, to));
|
||||
|
||||
// Publish queue reordered event
|
||||
Api::GlobalEventBus::instance().publish(
|
||||
emit(
|
||||
Api::Events::QueueReordered{.queueId = entry.queueId,
|
||||
.oldPosition = from,
|
||||
.newPosition = to,
|
||||
@@ -768,7 +768,7 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
// Publish shuffle changed event
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::ShuffleChanged{
|
||||
emit(Api::Events::ShuffleChanged{
|
||||
.enabled = shuffle_, .changedByClientId = 0});
|
||||
|
||||
return shuffle_;
|
||||
@@ -815,7 +815,7 @@ namespace Echoion::Core
|
||||
ECHOION_LOG_INFO(repeat_ ? "Repeat enabled" : "Repeat disabled");
|
||||
|
||||
// Publish repeat changed event
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::RepeatChanged{
|
||||
emit(Api::Events::RepeatChanged{
|
||||
.enabled = repeat_, .changedByClientId = 0});
|
||||
|
||||
return repeat_;
|
||||
@@ -865,7 +865,7 @@ namespace Echoion::Core
|
||||
std::format("Starting async playlist load: {}", playlistId));
|
||||
|
||||
// Publish playlist load started event
|
||||
Api::GlobalEventBus::instance().publish(
|
||||
emit(
|
||||
Api::Events::PlaylistLoadStarted{.playlistId = playlistId,
|
||||
.requestedByClientId = clientId});
|
||||
|
||||
@@ -899,7 +899,7 @@ namespace Echoion::Core
|
||||
added.fetch_add(1);
|
||||
|
||||
// Publish playlist track loaded event
|
||||
Api::GlobalEventBus::instance().publish(
|
||||
emit(
|
||||
Api::Events::PlaylistTrackLoaded{
|
||||
.playlistId = playlistId,
|
||||
.track = track,
|
||||
@@ -954,7 +954,7 @@ namespace Echoion::Core
|
||||
playlistLoading_ = false;
|
||||
|
||||
// Publish playlist load completed event
|
||||
Api::GlobalEventBus::instance().publish(
|
||||
emit(
|
||||
Api::Events::PlaylistLoadCompleted{
|
||||
.playlistId = playlistId,
|
||||
.totalTracksLoaded = added.load(),
|
||||
@@ -1427,7 +1427,7 @@ namespace Echoion::Core
|
||||
100.0f;
|
||||
}
|
||||
|
||||
Api::GlobalEventBus::instance().publish(
|
||||
emit(
|
||||
Api::Events::PlaybackPositionChanged{
|
||||
.track = currentTrack_->track,
|
||||
.position = position,
|
||||
@@ -1723,7 +1723,7 @@ namespace Echoion::Core
|
||||
|
||||
// Publish track finished event
|
||||
if (currentTrack_.has_value()) {
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::TrackFinished{
|
||||
emit(Api::Events::TrackFinished{
|
||||
.track = currentTrack_->track,
|
||||
.autoSkipped = false,
|
||||
.finalPosition = getPlaybackPosition()});
|
||||
@@ -1928,7 +1928,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
}
|
||||
|
||||
// Publish subscription event
|
||||
Api::GlobalEventBus::instance().publish(Api::Events::UserSubscribed{
|
||||
emit(Api::Events::UserSubscribed{
|
||||
.uid = uid, .nickname = nickname, .clientId = clientId});
|
||||
|
||||
if (added) {
|
||||
@@ -1976,7 +1976,7 @@ Subscriptions are persistent across server reconnects.)";
|
||||
|
||||
// Publish unsubscription event
|
||||
if (removed) {
|
||||
Api::GlobalEventBus::instance().publish(
|
||||
emit(
|
||||
Api::Events::UserUnsubscribed{
|
||||
.uid = uid, .nickname = nickname, .clientId = clientId});
|
||||
return "You are now unsubscribed from the bot's audio output.";
|
||||
|
||||
Reference in new issue
Block a user