diff --git a/server/TracyView.cpp b/server/TracyView.cpp index ec0add6c..db07addc 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -1,5 +1,12 @@ +#ifdef _MSC_VER +# include +#else +# include +#endif + #include +#include "../common/TracySocket.hpp" #include "../common/TracySystem.hpp" #include "TracyView.hpp" @@ -30,10 +37,30 @@ View::~View() void View::Worker() { + Socket sock; + + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 10000; + for(;;) { if( m_shutdown.load( std::memory_order_relaxed ) ) return; - std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); + if( !sock.Connect( m_addr.c_str(), "8086" ) ) continue; + + sock.Recv( &m_timeBegin, sizeof( m_timeBegin ), nullptr ); + + uint8_t lz4; + sock.Recv( &lz4, 1, nullptr ); + + for(;;) + { + if( m_shutdown.load( std::memory_order_relaxed ) ) return; + char buf[16*1024]; + if( sock.Recv( buf, 16*1024, &tv ) == 0 ) break; + } + + sock.Close(); } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 72d1585b..a2ec514b 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -22,6 +22,8 @@ private: std::thread m_thread; std::atomic m_shutdown; + + int64_t m_timeBegin; }; }