diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index b8128860..ac70ae97 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -37,6 +37,7 @@ #include "../../server/TracyMouse.hpp" #include "../../server/TracyPrint.hpp" #include "../../server/TracyStorage.hpp" +#include "../../server/TracyVersion.hpp" #include "../../server/TracyView.hpp" #include "../../server/TracyWorker.hpp" #include "../../server/TracyVersion.hpp" @@ -117,7 +118,7 @@ static tracy::BadVersionState badVer; static int port = 8086; static const char* connectTo = nullptr; static char title[128]; -static std::thread loadThread; +static std::thread loadThread, updateThread; static std::unique_ptr broadcastListen; static std::mutex resolvLock; static tracy::unordered_flat_map resolvMap; @@ -135,6 +136,7 @@ static ImGuiTextFilter addrFilter, portFilter, progFilter; static std::thread::id mainThread; static std::vector> mainThreadTasks; static std::mutex mainThreadLock; +static uint32_t updateVersion = 0; void RunOnMainThread( std::function cb ) { @@ -223,6 +225,21 @@ int main( int argc, char** argv ) mainThread = std::this_thread::get_id(); + updateThread = std::thread( [] { + tracy::Socket sock; + if( !sock.ConnectBlocking( "51.89.23.220", 8099 ) ) return; + char request[1024]; + const auto len = sprintf( request, "GET /tracy/version HTTP/1.1\r\nHost: 51.89.23.220\r\nUser-Agent: Tracy Profiler %i.%i.%i\r\nConnection: close\r\nCache-Control: no-cache, no-store, must-revalidate\r\n\r\n", tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch ); + sock.Send( request, len ); + char response[1024]; + const auto sz = sock.ReadUpTo( response, 1024, 15 ); + if( sz < 13 ) return; + if( memcmp( response, "HTTP/1.1 200", 12 ) != 0 ) return; + uint32_t ver; + memcpy( &ver, response + sz - 4, 4 ); + RunOnMainThread( [ver] { updateVersion = ver; } ); + } ); + // Setup window glfwSetErrorCallback(glfw_error_callback); if( !glfwInit() ) return 1; @@ -369,6 +386,7 @@ int main( int argc, char** argv ) } if( loadThread.joinable() ) loadThread.join(); + if( updateThread.joinable() ) updateThread.join(); view.reset(); {