#include #include #include #include #include "messaging.hpp" namespace hex::messaging { void messageReceived(const std::string &eventName, const std::vector &args) { log::debug("Received event '{}' with size {}", eventName, args.size()); ImHexApi::Messaging::impl::runHandler(eventName, args); } void setupEvents() { SendMessageToMainInstance::subscribe([](const std::string &eventName, const std::vector &eventData) { log::debug("Forwarding message {} (maybe to us)", eventName); if (ImHexApi::System::isMainInstance()) { EventImHexStartupFinished::subscribe([eventName, eventData]{ ImHexApi::Messaging::impl::runHandler(eventName, eventData); }); } else { sendToOtherInstance(eventName, eventData); } }); } void setupMessaging() { ImHexApi::System::impl::setMainInstanceStatus(setupNative()); setupEvents(); } }