1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Allow specifying network port in server.

This commit is contained in:
Bartosz Taudul
2019-09-21 15:43:01 +02:00
parent fb63dd89bc
commit 82cd667b30
10 changed files with 58 additions and 23 deletions
+3 -2
View File
@@ -8,8 +8,9 @@
#include "ResolvService.hpp"
ResolvService::ResolvService()
ResolvService::ResolvService( int port )
: m_exit( false )
, m_port( port )
, m_thread( [this] { Worker(); } )
{
}
@@ -32,7 +33,7 @@ void ResolvService::Worker()
{
struct sockaddr_in addr = {};
addr.sin_family = AF_INET;
addr.sin_port = 8086;
addr.sin_port = m_port;
char buf[128];
+2 -1
View File
@@ -19,7 +19,7 @@ class ResolvService
};
public:
ResolvService();
ResolvService( int port );
~ResolvService();
void Query( uint32_t ip, const std::function<void(std::string&&)>& callback );
@@ -31,6 +31,7 @@ private:
std::mutex m_lock;
std::condition_variable m_cv;
std::vector<QueueItem> m_queue;
int m_port;
std::thread m_thread;
};
+30 -6
View File
@@ -104,6 +104,9 @@ int main( int argc, char** argv )
std::unique_ptr<tracy::View> view;
tracy::BadVersionState badVer;
int port = 8086;
const char* connectTo = nullptr;
if( argc == 2 )
{
auto f = std::unique_ptr<tracy::FileRead>( tracy::FileRead::Open( argv[1] ) );
@@ -112,9 +115,30 @@ int main( int argc, char** argv )
view = std::make_unique<tracy::View>( *f );
}
}
else if( argc == 3 && strcmp( argv[1], "-a" ) == 0 )
else
{
view = std::make_unique<tracy::View>( argv[2] );
while( argc >= 3 )
{
if( strcmp( argv[1], "-a" ) == 0 )
{
connectTo = argv[2];
}
else if( strcmp( argv[1], "-p" ) == 0 )
{
port = atoi( argv[2] );
}
else
{
fprintf( stderr, "Bad parameter: %s", argv[1] );
exit( 1 );
}
argc -= 2;
argv += 2;
}
}
if( connectTo )
{
view = std::make_unique<tracy::View>( connectTo, port );
}
char title[128];
@@ -261,7 +285,7 @@ int main( int argc, char** argv )
std::mutex resolvLock;
tracy::flat_hash_map<std::string, std::string> resolvMap;
ResolvService resolv;
ResolvService resolv( port );
glfwShowWindow( window );
@@ -296,7 +320,7 @@ int main( int argc, char** argv )
if( !broadcastListen )
{
broadcastListen = std::make_unique<tracy::UdpListen>();
if( !broadcastListen->Listen( 8086 ) )
if( !broadcastListen->Listen( port ) )
{
broadcastListen.reset();
}
@@ -456,7 +480,7 @@ int main( int argc, char** argv )
}
connHistVec = RebuildConnectionHistory( connHistMap );
view = std::make_unique<tracy::View>( addr, fixedWidth, smallFont, bigFont, SetWindowTitleCallback );
view = std::make_unique<tracy::View>( addr, port, fixedWidth, smallFont, bigFont, SetWindowTitleCallback );
}
ImGui::SameLine( 0, ImGui::GetFontSize() * 2 );
if( ImGui::Button( ICON_FA_FOLDER_OPEN " Open saved trace" ) && !loadThread.joinable() )
@@ -527,7 +551,7 @@ int main( int argc, char** argv )
if( badProto ) flags |= ImGuiSelectableFlags_Disabled;
if( ImGui::Selectable( name->second.c_str(), &sel, flags ) && !loadThread.joinable() )
{
view = std::make_unique<tracy::View>( v.second.address.c_str(), fixedWidth, smallFont, bigFont, SetWindowTitleCallback );
view = std::make_unique<tracy::View>( v.second.address.c_str(), port, fixedWidth, smallFont, bigFont, SetWindowTitleCallback );
}
ImGui::NextColumn();
const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll;