MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ as_osc()

MAYAFLUX_API std::optional< Core::InputValue::OSCMessage > MayaFlux::Portal::Network::as_osc ( const Core::NetworkMessage msg)

Parse a NetworkMessage payload as an OSC message.

Intended for coroutine consumers that receive a Core::NetworkMessage from co_await source->next_message() and need a typed value without manual parsing or visitor boilerplate.

auto msg = co_await source->next_message();
if (auto osc = Portal::Network::as_osc(msg)) {
float val = osc->get_float(0).value_or(0.0f);
}
std::optional< Core::InputValue::OSCMessage > as_osc(const Core::NetworkMessage &msg)
Parse a NetworkMessage payload as an OSC message.
Parameters
msgNetworkMessage received from a NetworkSource.
Returns
Parsed OSCMessage, or std::nullopt if the payload is not valid OSC.

Definition at line 8 of file MessageUtils.cpp.

9{
10 auto result = Core::OscParser::parse(msg.data.data(), msg.data.size());
11 if (!result || result->type != Core::InputValue::Type::OSC) {
12 return std::nullopt;
13 }
14 return result->as_osc();
15}

References MayaFlux::Core::NetworkMessage::data, MayaFlux::Core::InputValue::OSC, and MayaFlux::Core::OscParser::parse().

+ Here is the call graph for this function: