mirror of https://github.com/infosecn1nja/C3.git
Move implementation to .cpp
parent
686bbdeb9c
commit
89aa4dde63
|
@ -173,8 +173,7 @@ void MWR::C3::Core::GateRelay::RunApiBrige(std::string_view apiBrigdeIp, std::ui
|
||||||
{
|
{
|
||||||
// Read socket.
|
// Read socket.
|
||||||
std::this_thread::sleep_for(300ms);
|
std::this_thread::sleep_for(300ms);
|
||||||
auto newSnapshot = sp.GetSnapshotIfChanged();
|
if (auto newSnapshot = sp.GetSnapshotIfChanged())
|
||||||
if (newSnapshot)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1530,3 +1530,21 @@ json MWR::C3::Core::Profiler::Channel::CreateProfileSnapshot() const
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
MWR::C3::Core::Profiler::SnapshotProxy::SnapshotProxy(Profiler& profiler) :
|
||||||
|
m_Profiler(profiler)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::optional<MWR::json> MWR::C3::Core::Profiler::SnapshotProxy::GetSnapshotIfChanged()
|
||||||
|
{
|
||||||
|
auto currentSnapshot = m_Profiler.Get().m_Gateway.CreateProfileSnapshot();
|
||||||
|
auto currentHash = std::hash<json>{}(currentSnapshot);
|
||||||
|
if (previousHash && currentHash == *previousHash)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
previousHash = currentHash;
|
||||||
|
return currentSnapshot;
|
||||||
|
}
|
||||||
|
|
|
@ -542,23 +542,11 @@ namespace MWR::C3::Core
|
||||||
public:
|
public:
|
||||||
/// Create a snapshot proxy
|
/// Create a snapshot proxy
|
||||||
/// @param profiler to wrap CreateProfileShnapshot calls
|
/// @param profiler to wrap CreateProfileShnapshot calls
|
||||||
SnapshotProxy(Profiler& profiler) :
|
SnapshotProxy(Profiler& profiler);
|
||||||
m_Profiler(profiler)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a snapshot
|
/// Create a snapshot
|
||||||
/// @return std::nullopt if snaphot hasn't change since the last call
|
/// @return std::nullopt if snaphot hasn't change since the last call
|
||||||
std::optional<json> GetSnapshotIfChanged()
|
std::optional<json> GetSnapshotIfChanged();
|
||||||
{
|
|
||||||
auto currentSnapshot = m_Profiler.Get().m_Gateway.CreateProfileSnapshot();
|
|
||||||
auto currentHash = std::hash<json>{}(currentSnapshot);
|
|
||||||
if (previousHash && currentHash == *previousHash)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
previousHash = currentHash;
|
|
||||||
return currentSnapshot;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Proxied profiler
|
/// Proxied profiler
|
||||||
|
|
Loading…
Reference in New Issue