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
@@ -7,6 +7,7 @@
|
|||||||
#include "RpcServer.hpp"
|
#include "RpcServer.hpp"
|
||||||
#include <ConfigTypes.hpp>
|
#include <ConfigTypes.hpp>
|
||||||
#include <CoreInterface.hpp>
|
#include <CoreInterface.hpp>
|
||||||
|
#include <Void/Async/EventBus.hpp>
|
||||||
#include <Database.hpp>
|
#include <Database.hpp>
|
||||||
#include <RpcTypes.hpp>
|
#include <RpcTypes.hpp>
|
||||||
#include <StateBlob.hpp>
|
#include <StateBlob.hpp>
|
||||||
@@ -150,7 +151,7 @@ namespace Echoion::Core
|
|||||||
[[nodiscard]] bool isAdmin(uint64_t clientId) const;
|
[[nodiscard]] bool isAdmin(uint64_t clientId) const;
|
||||||
void updateWhisperList();
|
void updateWhisperList();
|
||||||
void setupRpcHandlers();
|
void setupRpcHandlers();
|
||||||
void setupEventBusSubscriptions() const noexcept;
|
void setupEventBusSubscriptions() noexcept;
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
std::shared_ptr<NetworkClient> networkClient_;
|
std::shared_ptr<NetworkClient> networkClient_;
|
||||||
@@ -186,6 +187,11 @@ namespace Echoion::Core
|
|||||||
// shims over the same instances.
|
// shims over the same instances.
|
||||||
Void::Service::ServiceRegistry registry_;
|
Void::Service::ServiceRegistry registry_;
|
||||||
|
|
||||||
|
// Application event bus (async): playback/queue/subscription events
|
||||||
|
// published by MusicManager and consumed here for RPC broadcast +
|
||||||
|
// DB persistence. Owned by Core, provided as a service.
|
||||||
|
Void::EventBus::EventBus eventBus_{Void::EventBus::Mode::Async};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Access the service registry (composition root).
|
// Access the service registry (composition root).
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <ConfigTypes.hpp>
|
#include <ConfigTypes.hpp>
|
||||||
#include <TrackTypes.hpp>
|
#include <TrackTypes.hpp>
|
||||||
#include <Types.hpp>
|
#include <Types.hpp>
|
||||||
|
#include <Void/Async/EventBus.hpp>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@@ -36,6 +37,10 @@ namespace Echoion::Core
|
|||||||
std::shared_ptr<Api::Database> database = nullptr);
|
std::shared_ptr<Api::Database> database = nullptr);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
// Inject the application event bus (owned by Core). Must be set
|
||||||
|
// before playback so emitted events reach subscribers.
|
||||||
|
void setEventBus(Void::EventBus::EventBus* bus) { eventBus_ = bus; }
|
||||||
|
|
||||||
[[nodiscard]] Api::Result<std::string>
|
[[nodiscard]] Api::Result<std::string>
|
||||||
play(const std::string& query, uint64_t clientId);
|
play(const std::string& query, uint64_t clientId);
|
||||||
[[nodiscard]] Api::Result<void> pause();
|
[[nodiscard]] Api::Result<void> pause();
|
||||||
@@ -157,6 +162,14 @@ namespace Echoion::Core
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// Publish a domain event on the injected bus (no-op until set).
|
||||||
|
template <typename T> void emit(T event)
|
||||||
|
{
|
||||||
|
if (eventBus_) {
|
||||||
|
eventBus_->publish<T>(std::move(event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void playbackThread();
|
void playbackThread();
|
||||||
[[nodiscard]] Api::Result<Api::TrackInfo>
|
[[nodiscard]] Api::Result<Api::TrackInfo>
|
||||||
resolveQuery(const std::string& query);
|
resolveQuery(const std::string& query);
|
||||||
@@ -207,6 +220,8 @@ namespace Echoion::Core
|
|||||||
std::thread playlistAutoStartThread_;
|
std::thread playlistAutoStartThread_;
|
||||||
|
|
||||||
std::shared_ptr<NetworkClient> networkClient_;
|
std::shared_ptr<NetworkClient> networkClient_;
|
||||||
|
// Non-owning application event bus (provided by Core).
|
||||||
|
Void::EventBus::EventBus* eventBus_ = nullptr;
|
||||||
std::unique_ptr<YouTubeClient> youTubeClient_;
|
std::unique_ptr<YouTubeClient> youTubeClient_;
|
||||||
std::unique_ptr<AudioDecoder> audioDecoder_;
|
std::unique_ptr<AudioDecoder> audioDecoder_;
|
||||||
std::unique_ptr<SubscriptionManager> subscriptionManager_;
|
std::unique_ptr<SubscriptionManager> subscriptionManager_;
|
||||||
|
|||||||
+26
-27
@@ -6,7 +6,7 @@
|
|||||||
#include "echoion/core/state/StateVersions.hpp"
|
#include "echoion/core/state/StateVersions.hpp"
|
||||||
#include <ConfigManager.hpp>
|
#include <ConfigManager.hpp>
|
||||||
#include <Database.hpp>
|
#include <Database.hpp>
|
||||||
#include <EventBus.hpp>
|
#include <Events.hpp>
|
||||||
#include <Void/Data/Json.hpp>
|
#include <Void/Data/Json.hpp>
|
||||||
#include <Void/Data/Reflect.hpp>
|
#include <Void/Data/Reflect.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -80,9 +80,8 @@ namespace Echoion::Core
|
|||||||
|
|
||||||
ECHOION_LOG_INFO("Initializing Echoion Core...");
|
ECHOION_LOG_INFO("Initializing Echoion Core...");
|
||||||
|
|
||||||
// Start EventBus processing thread
|
// The async event bus runs from construction; nothing to start.
|
||||||
Api::GlobalEventBus::instance().start();
|
ECHOION_LOG_INFO("EventBus ready");
|
||||||
ECHOION_LOG_INFO("EventBus started");
|
|
||||||
|
|
||||||
// Initialize network client
|
// Initialize network client
|
||||||
networkClient_ = std::make_shared<NetworkClient>();
|
networkClient_ = std::make_shared<NetworkClient>();
|
||||||
@@ -110,6 +109,7 @@ namespace Echoion::Core
|
|||||||
|
|
||||||
// Initialize music manager
|
// Initialize music manager
|
||||||
musicManager_ = std::make_shared<MusicManager>();
|
musicManager_ = std::make_shared<MusicManager>();
|
||||||
|
musicManager_->setEventBus(&eventBus_);
|
||||||
auto musicResult = musicManager_->initialize(networkClient_, database_);
|
auto musicResult = musicManager_->initialize(networkClient_, database_);
|
||||||
if (!musicResult) {
|
if (!musicResult) {
|
||||||
return std::unexpected(musicResult.error());
|
return std::unexpected(musicResult.error());
|
||||||
@@ -307,8 +307,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
registry_.provide<Api::ConfigManager>(
|
registry_.provide<Api::ConfigManager>(
|
||||||
alias(&Api::ConfigManager::instance()));
|
alias(&Api::ConfigManager::instance()));
|
||||||
registry_.provide<Api::EventBus>(
|
registry_.provide<Void::EventBus::EventBus>(alias(&eventBus_));
|
||||||
alias(&Api::GlobalEventBus::instance()));
|
|
||||||
if (networkClient_) {
|
if (networkClient_) {
|
||||||
registry_.provide<Api::INetworkClient>(networkClient_);
|
registry_.provide<Api::INetworkClient>(networkClient_);
|
||||||
}
|
}
|
||||||
@@ -395,8 +394,8 @@ namespace Echoion::Core
|
|||||||
database_.reset();
|
database_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop EventBus
|
// Drain any in-flight event dispatch.
|
||||||
Api::GlobalEventBus::instance().stop();
|
eventBus_.flush();
|
||||||
ECHOION_LOG_INFO("EventBus stopped");
|
ECHOION_LOG_INFO("EventBus stopped");
|
||||||
|
|
||||||
// Clear callbacks
|
// Clear callbacks
|
||||||
@@ -1796,13 +1795,13 @@ namespace Echoion::Core
|
|||||||
ECHOION_LOG_INFO("RPC handlers registered");
|
ECHOION_LOG_INFO("RPC handlers registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::setupEventBusSubscriptions() const noexcept
|
void Core::setupEventBusSubscriptions() noexcept
|
||||||
{
|
{
|
||||||
using namespace Api::Events;
|
using namespace Api::Events;
|
||||||
|
|
||||||
// Subscribe to playback events for RPC broadcasting and database
|
// Subscribe to playback events for RPC broadcasting and database
|
||||||
// persistence
|
// persistence
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaybackStarted>(
|
eventBus_.subscribe<PlaybackStarted>(
|
||||||
[this](const PlaybackStarted& evt) mutable {
|
[this](const PlaybackStarted& evt) mutable {
|
||||||
// Broadcast to RPC/WebSocket clients
|
// Broadcast to RPC/WebSocket clients
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
@@ -1822,7 +1821,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaybackPaused>(
|
eventBus_.subscribe<PlaybackPaused>(
|
||||||
[this](const PlaybackPaused& evt) mutable {
|
[this](const PlaybackPaused& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data = std::format("{{\"position\":{}}}",
|
std::string data = std::format("{{\"position\":{}}}",
|
||||||
@@ -1831,7 +1830,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaybackResumed>(
|
eventBus_.subscribe<PlaybackResumed>(
|
||||||
[this](const PlaybackResumed& evt) mutable {
|
[this](const PlaybackResumed& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data = std::format("{{\"position\":{}}}",
|
std::string data = std::format("{{\"position\":{}}}",
|
||||||
@@ -1840,14 +1839,14 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaybackStopped>(
|
eventBus_.subscribe<PlaybackStopped>(
|
||||||
[this](const PlaybackStopped& evt) mutable {
|
[this](const PlaybackStopped& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
rpcServer_->broadcastEvent("playback.stopped", "{}");
|
rpcServer_->broadcastEvent("playback.stopped", "{}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaybackPositionChanged>(
|
eventBus_.subscribe<PlaybackPositionChanged>(
|
||||||
[this](const PlaybackPositionChanged& evt) mutable {
|
[this](const PlaybackPositionChanged& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data =
|
std::string data =
|
||||||
@@ -1859,7 +1858,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<TrackFinished>(
|
eventBus_.subscribe<TrackFinished>(
|
||||||
[this](const TrackFinished& evt) mutable {
|
[this](const TrackFinished& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
rpcServer_->broadcastEvent("playback.finished", "{}");
|
rpcServer_->broadcastEvent("playback.finished", "{}");
|
||||||
@@ -1873,7 +1872,7 @@ namespace Echoion::Core
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Volume and playback mode changes
|
// Volume and playback mode changes
|
||||||
Api::GlobalEventBus::instance().subscribe<VolumeChanged>(
|
eventBus_.subscribe<VolumeChanged>(
|
||||||
[this](const VolumeChanged& evt) mutable {
|
[this](const VolumeChanged& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data =
|
std::string data =
|
||||||
@@ -1882,7 +1881,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<ShuffleChanged>(
|
eventBus_.subscribe<ShuffleChanged>(
|
||||||
[this](const ShuffleChanged& evt) mutable {
|
[this](const ShuffleChanged& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data = std::format(
|
std::string data = std::format(
|
||||||
@@ -1891,7 +1890,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<RepeatChanged>(
|
eventBus_.subscribe<RepeatChanged>(
|
||||||
[this](const RepeatChanged& evt) mutable {
|
[this](const RepeatChanged& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data = std::format(
|
std::string data = std::format(
|
||||||
@@ -1901,7 +1900,7 @@ namespace Echoion::Core
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Queue events
|
// Queue events
|
||||||
Api::GlobalEventBus::instance().subscribe<TrackQueued>(
|
eventBus_.subscribe<TrackQueued>(
|
||||||
[this](const TrackQueued& evt) mutable {
|
[this](const TrackQueued& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data = std::format(
|
std::string data = std::format(
|
||||||
@@ -1913,7 +1912,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<TrackRemoved>(
|
eventBus_.subscribe<TrackRemoved>(
|
||||||
[this](const TrackRemoved& evt) mutable {
|
[this](const TrackRemoved& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data =
|
std::string data =
|
||||||
@@ -1923,14 +1922,14 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<QueueCleared>(
|
eventBus_.subscribe<QueueCleared>(
|
||||||
[this](const QueueCleared& evt) mutable {
|
[this](const QueueCleared& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
rpcServer_->broadcastEvent("queue.cleared", "{}");
|
rpcServer_->broadcastEvent("queue.cleared", "{}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<QueueReordered>(
|
eventBus_.subscribe<QueueReordered>(
|
||||||
[this](const QueueReordered& evt) mutable {
|
[this](const QueueReordered& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data = std::format(
|
std::string data = std::format(
|
||||||
@@ -1942,7 +1941,7 @@ namespace Echoion::Core
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Playlist events - save to database via event bus using external ID
|
// Playlist events - save to database via event bus using external ID
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaylistLoadStarted>(
|
eventBus_.subscribe<PlaylistLoadStarted>(
|
||||||
[this](const PlaylistLoadStarted& evt) mutable {
|
[this](const PlaylistLoadStarted& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data = std::string("{\"playlistId\":\"") +
|
std::string data = std::string("{\"playlistId\":\"") +
|
||||||
@@ -1957,7 +1956,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaylistTrackLoaded>(
|
eventBus_.subscribe<PlaylistTrackLoaded>(
|
||||||
[this](const PlaylistTrackLoaded& evt) mutable {
|
[this](const PlaylistTrackLoaded& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data =
|
std::string data =
|
||||||
@@ -1979,7 +1978,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<PlaylistLoadCompleted>(
|
eventBus_.subscribe<PlaylistLoadCompleted>(
|
||||||
[this](const PlaylistLoadCompleted& evt) mutable {
|
[this](const PlaylistLoadCompleted& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data =
|
std::string data =
|
||||||
@@ -1993,7 +1992,7 @@ namespace Echoion::Core
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Subscription events
|
// Subscription events
|
||||||
Api::GlobalEventBus::instance().subscribe<UserSubscribed>(
|
eventBus_.subscribe<UserSubscribed>(
|
||||||
[this](const UserSubscribed& evt) mutable {
|
[this](const UserSubscribed& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data =
|
std::string data =
|
||||||
@@ -2003,7 +2002,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().subscribe<UserUnsubscribed>(
|
eventBus_.subscribe<UserUnsubscribed>(
|
||||||
[this](const UserUnsubscribed& evt) mutable {
|
[this](const UserUnsubscribed& evt) mutable {
|
||||||
if (rpcServer_) {
|
if (rpcServer_) {
|
||||||
std::string data =
|
std::string data =
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
#include <EventBus.hpp>
|
|
||||||
|
|
||||||
namespace Echoion::Api
|
|
||||||
{
|
|
||||||
|
|
||||||
// Global event bus instance. The EventBus type is otherwise header-only
|
|
||||||
// (it delegates to Void::EventBus); only the singleton lives here.
|
|
||||||
EventBus& GlobalEventBus::instance()
|
|
||||||
{
|
|
||||||
static EventBus instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Echoion::Api
|
|
||||||
+15
-15
@@ -1,7 +1,7 @@
|
|||||||
#include "ConfigManager.hpp"
|
#include "ConfigManager.hpp"
|
||||||
#include "LoggerInterface.hpp"
|
#include "LoggerInterface.hpp"
|
||||||
#include "echoion/core/MusicManager.hpp"
|
#include "echoion/core/MusicManager.hpp"
|
||||||
#include <EventBus.hpp>
|
#include <Events.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <execution>
|
#include <execution>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@@ -396,7 +396,7 @@ namespace Echoion::Core
|
|||||||
ECHOION_LOG_INFO("Playback stopped");
|
ECHOION_LOG_INFO("Playback stopped");
|
||||||
|
|
||||||
// Publish playback stopped event
|
// Publish playback stopped event
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::PlaybackStopped{
|
emit(Api::Events::PlaybackStopped{
|
||||||
.lastTrack = currentTrack_ ? std::optional(currentTrack_->track)
|
.lastTrack = currentTrack_ ? std::optional(currentTrack_->track)
|
||||||
: std::nullopt,
|
: std::nullopt,
|
||||||
.finalPosition = playbackPosition_});
|
.finalPosition = playbackPosition_});
|
||||||
@@ -493,7 +493,7 @@ namespace Echoion::Core
|
|||||||
ECHOION_LOG_INFO(std::format("Volume set to {}", volume));
|
ECHOION_LOG_INFO(std::format("Volume set to {}", volume));
|
||||||
|
|
||||||
// Publish volume changed event
|
// Publish volume changed event
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::VolumeChanged{
|
emit(Api::Events::VolumeChanged{
|
||||||
.oldVolume = oldVolume,
|
.oldVolume = oldVolume,
|
||||||
.newVolume = volume,
|
.newVolume = volume,
|
||||||
.changedByClientId = 0 // Will be set by caller if available
|
.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));
|
ECHOION_LOG_INFO(std::format("Removed track at position {}", position));
|
||||||
|
|
||||||
// Publish track removed event
|
// Publish track removed event
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::TrackRemoved{
|
emit(Api::Events::TrackRemoved{
|
||||||
.track = removedTrack.track,
|
.track = removedTrack.track,
|
||||||
.queueId = removedTrack.queueId,
|
.queueId = removedTrack.queueId,
|
||||||
.removedByClientId = 0,
|
.removedByClientId = 0,
|
||||||
@@ -687,7 +687,7 @@ namespace Echoion::Core
|
|||||||
ECHOION_LOG_INFO("Queue cleared");
|
ECHOION_LOG_INFO("Queue cleared");
|
||||||
|
|
||||||
// Publish queue cleared event
|
// Publish queue cleared event
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::QueueCleared{
|
emit(Api::Events::QueueCleared{
|
||||||
.clearedByClientId = 0, .previousLength = previousLength});
|
.clearedByClientId = 0, .previousLength = previousLength});
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@@ -738,7 +738,7 @@ namespace Echoion::Core
|
|||||||
ECHOION_LOG_INFO(std::format("Moved track from {} to {}", from, to));
|
ECHOION_LOG_INFO(std::format("Moved track from {} to {}", from, to));
|
||||||
|
|
||||||
// Publish queue reordered event
|
// Publish queue reordered event
|
||||||
Api::GlobalEventBus::instance().publish(
|
emit(
|
||||||
Api::Events::QueueReordered{.queueId = entry.queueId,
|
Api::Events::QueueReordered{.queueId = entry.queueId,
|
||||||
.oldPosition = from,
|
.oldPosition = from,
|
||||||
.newPosition = to,
|
.newPosition = to,
|
||||||
@@ -768,7 +768,7 @@ namespace Echoion::Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Publish shuffle changed event
|
// Publish shuffle changed event
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::ShuffleChanged{
|
emit(Api::Events::ShuffleChanged{
|
||||||
.enabled = shuffle_, .changedByClientId = 0});
|
.enabled = shuffle_, .changedByClientId = 0});
|
||||||
|
|
||||||
return shuffle_;
|
return shuffle_;
|
||||||
@@ -815,7 +815,7 @@ namespace Echoion::Core
|
|||||||
ECHOION_LOG_INFO(repeat_ ? "Repeat enabled" : "Repeat disabled");
|
ECHOION_LOG_INFO(repeat_ ? "Repeat enabled" : "Repeat disabled");
|
||||||
|
|
||||||
// Publish repeat changed event
|
// Publish repeat changed event
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::RepeatChanged{
|
emit(Api::Events::RepeatChanged{
|
||||||
.enabled = repeat_, .changedByClientId = 0});
|
.enabled = repeat_, .changedByClientId = 0});
|
||||||
|
|
||||||
return repeat_;
|
return repeat_;
|
||||||
@@ -865,7 +865,7 @@ namespace Echoion::Core
|
|||||||
std::format("Starting async playlist load: {}", playlistId));
|
std::format("Starting async playlist load: {}", playlistId));
|
||||||
|
|
||||||
// Publish playlist load started event
|
// Publish playlist load started event
|
||||||
Api::GlobalEventBus::instance().publish(
|
emit(
|
||||||
Api::Events::PlaylistLoadStarted{.playlistId = playlistId,
|
Api::Events::PlaylistLoadStarted{.playlistId = playlistId,
|
||||||
.requestedByClientId = clientId});
|
.requestedByClientId = clientId});
|
||||||
|
|
||||||
@@ -899,7 +899,7 @@ namespace Echoion::Core
|
|||||||
added.fetch_add(1);
|
added.fetch_add(1);
|
||||||
|
|
||||||
// Publish playlist track loaded event
|
// Publish playlist track loaded event
|
||||||
Api::GlobalEventBus::instance().publish(
|
emit(
|
||||||
Api::Events::PlaylistTrackLoaded{
|
Api::Events::PlaylistTrackLoaded{
|
||||||
.playlistId = playlistId,
|
.playlistId = playlistId,
|
||||||
.track = track,
|
.track = track,
|
||||||
@@ -954,7 +954,7 @@ namespace Echoion::Core
|
|||||||
playlistLoading_ = false;
|
playlistLoading_ = false;
|
||||||
|
|
||||||
// Publish playlist load completed event
|
// Publish playlist load completed event
|
||||||
Api::GlobalEventBus::instance().publish(
|
emit(
|
||||||
Api::Events::PlaylistLoadCompleted{
|
Api::Events::PlaylistLoadCompleted{
|
||||||
.playlistId = playlistId,
|
.playlistId = playlistId,
|
||||||
.totalTracksLoaded = added.load(),
|
.totalTracksLoaded = added.load(),
|
||||||
@@ -1427,7 +1427,7 @@ namespace Echoion::Core
|
|||||||
100.0f;
|
100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Api::GlobalEventBus::instance().publish(
|
emit(
|
||||||
Api::Events::PlaybackPositionChanged{
|
Api::Events::PlaybackPositionChanged{
|
||||||
.track = currentTrack_->track,
|
.track = currentTrack_->track,
|
||||||
.position = position,
|
.position = position,
|
||||||
@@ -1723,7 +1723,7 @@ namespace Echoion::Core
|
|||||||
|
|
||||||
// Publish track finished event
|
// Publish track finished event
|
||||||
if (currentTrack_.has_value()) {
|
if (currentTrack_.has_value()) {
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::TrackFinished{
|
emit(Api::Events::TrackFinished{
|
||||||
.track = currentTrack_->track,
|
.track = currentTrack_->track,
|
||||||
.autoSkipped = false,
|
.autoSkipped = false,
|
||||||
.finalPosition = getPlaybackPosition()});
|
.finalPosition = getPlaybackPosition()});
|
||||||
@@ -1928,7 +1928,7 @@ Subscriptions are persistent across server reconnects.)";
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Publish subscription event
|
// Publish subscription event
|
||||||
Api::GlobalEventBus::instance().publish(Api::Events::UserSubscribed{
|
emit(Api::Events::UserSubscribed{
|
||||||
.uid = uid, .nickname = nickname, .clientId = clientId});
|
.uid = uid, .nickname = nickname, .clientId = clientId});
|
||||||
|
|
||||||
if (added) {
|
if (added) {
|
||||||
@@ -1976,7 +1976,7 @@ Subscriptions are persistent across server reconnects.)";
|
|||||||
|
|
||||||
// Publish unsubscription event
|
// Publish unsubscription event
|
||||||
if (removed) {
|
if (removed) {
|
||||||
Api::GlobalEventBus::instance().publish(
|
emit(
|
||||||
Api::Events::UserUnsubscribed{
|
Api::Events::UserUnsubscribed{
|
||||||
.uid = uid, .nickname = nickname, .clientId = clientId});
|
.uid = uid, .nickname = nickname, .clientId = clientId});
|
||||||
return "You are now unsubscribed from the bot's audio output.";
|
return "You are now unsubscribed from the bot's audio output.";
|
||||||
|
|||||||
Reference in new issue
Block a user