Commit 68612de5 authored by Dominik Charousset's avatar Dominik Charousset

Generate random UUID on iOS/Android for node ID

Relates #263
parent f48167fa
...@@ -211,4 +211,30 @@ std::string get_root_uuid() { ...@@ -211,4 +211,30 @@ std::string get_root_uuid() {
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
#elif defined(CAF_IOS) || defined(CAF_ANDROID)
// return a randomly-generated UUID on mobile devices
#include <random>
namespace caf {
namespace detail {
std::string get_root_uuid() {
std::random_device rd;
std::uniform_int_distribution<int> dist(0, 15);
std::string uuid = uuid_format;
for (auto& c : uuid) {
if (c != '-') {
auto n = dist(rd);
c = static_cast<char>((n < 10) ? n + '0' : (n - 10) + 'A');
}
}
return uuid;
}
} // namespace detail
} // namespace caf
#endif // CAF_WINDOWS #endif // CAF_WINDOWS
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment