2023-07-13 14:08:23 +02:00
|
|
|
#if defined(OS_MACOS)
|
|
|
|
|
2023-11-10 20:47:08 +01:00
|
|
|
#include <stdexcept>
|
2023-07-13 14:08:23 +02:00
|
|
|
|
|
|
|
#include <hex/helpers/logger.hpp>
|
2025-01-26 18:50:19 +01:00
|
|
|
#include <hex/helpers/utils_macos.hpp>
|
2023-07-13 14:08:23 +02:00
|
|
|
|
|
|
|
#include "messaging.hpp"
|
|
|
|
|
|
|
|
namespace hex::messaging {
|
|
|
|
|
|
|
|
void sendToOtherInstance(const std::string &eventName, const std::vector<u8> &args) {
|
2025-01-26 18:50:19 +01:00
|
|
|
log::debug("Sending event {} to another instance (not us)", eventName);
|
|
|
|
|
|
|
|
// Create the message
|
|
|
|
std::vector<u8> fullEventData(eventName.begin(), eventName.end());
|
|
|
|
fullEventData.push_back('\0');
|
|
|
|
|
|
|
|
fullEventData.insert(fullEventData.end(), args.begin(), args.end());
|
|
|
|
|
|
|
|
u8 *data = &fullEventData[0];
|
|
|
|
auto dataSize = fullEventData.size();
|
|
|
|
|
|
|
|
macosSendMessageToMainInstance(data, dataSize);
|
2023-07-13 14:08:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool setupNative() {
|
2025-01-26 18:50:19 +01:00
|
|
|
macosInstallEventListener();
|
|
|
|
return macosIsMainInstance();
|
2023-07-13 14:08:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|