dispatch event intergration
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user