diff --git a/src/carrotjuicer/notifier.cpp b/src/carrotjuicer/notifier.cpp index 747cc912..30f6e78e 100644 --- a/src/carrotjuicer/notifier.cpp +++ b/src/carrotjuicer/notifier.cpp @@ -29,4 +29,18 @@ namespace notifier } } } + void notify_request(const std::string& data) + { + if (client == nullptr) { + init(); + } + + if (auto res = client->Post("/notify/request", data, "application/x-msgpack")) + { + if (res->status != 200) + { + std::cout << "Unexpected response from listener: " << res->status << "\n"; + } + } + } } diff --git a/src/carrotjuicer/notifier.hpp b/src/carrotjuicer/notifier.hpp index 23219a03..dad59e3f 100644 --- a/src/carrotjuicer/notifier.hpp +++ b/src/carrotjuicer/notifier.hpp @@ -10,4 +10,6 @@ namespace notifier void init(); void notify_response(const std::string& data); + + void notify_request(const std::string& data); } diff --git a/src/hook.cpp b/src/hook.cpp index 2a61c014..0d899d3f 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -85,6 +85,15 @@ namespace const int ret = reinterpret_cast(LZ4_compress_default_ext_orig)( src, dst, srcSize, dstCapacity); + const std::string data(src, srcSize); + + auto notifier_thread = std::thread([&] + { + notifier::notify_request(data); + }); + + notifier_thread.join(); + return ret; } void bootstrap_carrot_juicer()