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.
|
||||
std::this_thread::sleep_for(300ms);
|
||||
auto newSnapshot = sp.GetSnapshotIfChanged();
|
||||
if (newSnapshot)
|
||||
if (auto newSnapshot = sp.GetSnapshotIfChanged())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1530,3 +1530,21 @@ json MWR::C3::Core::Profiler::Channel::CreateProfileSnapshot() const
|
|||
|
||||
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:
|
||||
/// Create a snapshot proxy
|
||||
/// @param profiler to wrap CreateProfileShnapshot calls
|
||||
SnapshotProxy(Profiler& profiler) :
|
||||
m_Profiler(profiler)
|
||||
{
|
||||
}
|
||||
SnapshotProxy(Profiler& profiler);
|
||||
|
||||
/// Create a snapshot
|
||||
/// @return std::nullopt if snaphot hasn't change since the last call
|
||||
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;
|
||||
}
|
||||
std::optional<json> GetSnapshotIfChanged();
|
||||
|
||||
private:
|
||||
/// Proxied profiler
|
||||
|
|
Loading…
Reference in New Issue