1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-02 21:53:52 +00:00

Receive up-to-date tracy version.

This commit is contained in:
Bartosz Taudul 2020-09-10 21:40:19 +02:00
parent e2d69e7981
commit f5073e628d

View File

@ -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<tracy::UdpListen> broadcastListen;
static std::mutex resolvLock;
static tracy::unordered_flat_map<std::string, std::string> resolvMap;
@ -135,6 +136,7 @@ static ImGuiTextFilter addrFilter, portFilter, progFilter;
static std::thread::id mainThread;
static std::vector<std::function<void()>> mainThreadTasks;
static std::mutex mainThreadLock;
static uint32_t updateVersion = 0;
void RunOnMainThread( std::function<void()> 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();
{