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

◆ on_message()

MAYAFLUX_API Vruta::Event MayaFlux::Kriya::on_message ( std::shared_ptr< Vruta::NetworkSource source,
std::function< void(const Core::NetworkMessage &)>  callback 
)

Creates an Event coroutine that fires on every message received by a source.

Parameters
sourceShared ownership of the NetworkSource; lifetime is tied to the coroutine frame
callbackInvoked with each received message
Returns
Event coroutine suitable for EventManager::add_event()
auto src = std::make_shared<Vruta::NetworkSource>(
auto task = Kriya::on_message(src, [](const Core::NetworkMessage& msg) { });
Vruta::Event on_message(std::shared_ptr< Vruta::NetworkSource > source, std::function< void(const Core::NetworkMessage &)> callback)
Creates an Event coroutine that fires on every message received by a source.
Describes one logical send/receive endpoint managed by a backend.
A received datagram or framed message with sender metadata.

Definition at line 10 of file NetworkEvents.cpp.

13{
14 auto& promise = co_await GetEventPromise { source };
15
16 while (true) {
17 if (promise.should_terminate) {
18 break;
19 }
20
21 auto msg = co_await source->next_message();
22 callback(msg);
23 }
24}
Event-domain promise accessor with optional NetworkSource ownership transfer.

Referenced by MayaFlux::on_network_message().

+ Here is the caller graph for this function: