aboutsummaryrefslogtreecommitdiff
path: root/zencore/session.cpp
blob: ce4bfae1bc9b9afe2231b2094d366ccd4b44530f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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