aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/session.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/session.cpp')
-rw-r--r--src/zencore/session.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/zencore/session.cpp b/src/zencore/session.cpp
new file mode 100644
index 000000000..ce4bfae1b
--- /dev/null
+++ b/src/zencore/session.cpp
@@ -0,0 +1,35 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "zencore/session.h"
+
+#include <zencore/uid.h>
+
+#include <mutex>
+
+namespace zen {
+
+static Oid GlobalSessionId;
+static char GlobalSessionString[Oid::StringLength];
+static std::once_flag SessionInitFlag;
+
+Oid
+GetSessionId()
+{
+ std::call_once(SessionInitFlag, [&] {
+ GlobalSessionId.Generate();
+ GlobalSessionId.ToString(GlobalSessionString);
+ });
+
+ return GlobalSessionId;
+}
+
+std::string_view
+GetSessionIdString()
+{
+ // Ensure we actually have a generated session identifier
+ std::ignore = GetSessionId();
+
+ return std::string_view(GlobalSessionString, Oid::StringLength);
+}
+
+} // namespace zen \ No newline at end of file