dispatch event intergration
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m28s
CI / Windows Release Package (push) Successful in 2m24s

This commit is contained in:
Aiden
2026-05-11 15:42:14 +10:00
parent ccfc0237fd
commit a9b08f7f27
16 changed files with 785 additions and 59 deletions

View File

@@ -3,6 +3,7 @@
#include "ControlServer.h"
#include "OscServer.h"
#include "RuntimeControlBridge.h"
#include "RuntimeEventDispatcher.h"
#include "RuntimeStore.h"
#include <windows.h>
@@ -56,6 +57,8 @@ void ControlServices::BroadcastState()
void ControlServices::RequestBroadcastState()
{
PublishRuntimeStateBroadcastRequested("control-service-request");
if (mControlServer)
mControlServer->RequestBroadcastState();
}
@@ -105,6 +108,7 @@ bool ControlServices::ApplyPendingOscUpdates(std::vector<AppliedOscUpdate>& appl
appliedUpdate.parameterKey = entry.second.parameterKey;
appliedUpdate.targetValue = targetValue;
appliedUpdates.push_back(std::move(appliedUpdate));
PublishOscValueReceived(entry.second, entry.first);
}
(void)error;
@@ -195,6 +199,7 @@ void ControlServices::PollLoop(RuntimeCoordinator& runtimeCoordinator)
}
for (const auto& entry : pendingCommits)
{
PublishOscCommitRequested(entry.second);
const RuntimeCoordinatorResult result = runtimeCoordinator.CommitOscParameterByControlKey(
entry.second.layerKey,
entry.second.parameterKey,
@@ -233,3 +238,55 @@ void ControlServices::QueueRuntimeCoordinatorResult(const RuntimeCoordinatorResu
std::lock_guard<std::mutex> lock(mRuntimeCoordinatorResultMutex);
mRuntimeCoordinatorResults.push_back(std::move(serviceResult));
}
void ControlServices::PublishRuntimeStateBroadcastRequested(const std::string& reason)
{
try
{
RuntimeStateBroadcastRequestedEvent event;
event.reason = reason;
if (!mRuntimeEventDispatcher.PublishPayload(event, "ControlServices"))
OutputDebugStringA("RuntimeStateBroadcastRequested event publish failed.\n");
}
catch (...)
{
OutputDebugStringA("RuntimeStateBroadcastRequested event publish threw.\n");
}
}
void ControlServices::PublishOscValueReceived(const PendingOscUpdate& update, const std::string& routeKey)
{
try
{
OscValueReceivedEvent event;
event.routeKey = routeKey;
event.layerKey = update.layerKey;
event.parameterKey = update.parameterKey;
event.valueJson = update.valueJson;
if (!mRuntimeEventDispatcher.PublishPayload(event, "ControlServices"))
OutputDebugStringA("OscValueReceived event publish failed.\n");
}
catch (...)
{
OutputDebugStringA("OscValueReceived event publish threw.\n");
}
}
void ControlServices::PublishOscCommitRequested(const PendingOscCommit& commit)
{
try
{
OscCommitRequestedEvent event;
event.routeKey = commit.routeKey;
event.layerKey = commit.layerKey;
event.parameterKey = commit.parameterKey;
event.valueJson = SerializeJson(commit.value, false);
event.generation = commit.generation;
if (!mRuntimeEventDispatcher.PublishPayload(event, "ControlServices"))
OutputDebugStringA("OscCommitRequested event publish failed.\n");
}
catch (...)
{
OutputDebugStringA("OscCommitRequested event publish threw.\n");
}
}

View File

@@ -77,6 +77,9 @@ private:
void StopPolling();
void PollLoop(RuntimeCoordinator& runtimeCoordinator);
void QueueRuntimeCoordinatorResult(const RuntimeCoordinatorResult& result, bool failed = false);
void PublishRuntimeStateBroadcastRequested(const std::string& reason);
void PublishOscValueReceived(const PendingOscUpdate& update, const std::string& routeKey);
void PublishOscCommitRequested(const PendingOscCommit& commit);
std::unique_ptr<ControlServer> mControlServer;
std::unique_ptr<OscServer> mOscServer;