Broadcast protocol version and process name.

This commit is contained in:
Bartosz Taudul 2019-06-17 18:34:35 +02:00
parent 0b9ef7e514
commit 1b3b3a94a2

View File

@ -422,6 +422,23 @@ static const char* GetHostInfo()
return buf; return buf;
} }
static const char* GetBroadcastMessage( const char* procname, int& len )
{
static char buf[1024];
char* ptr = buf;
const uint32_t protoVer = ProtocolVersion;
memcpy( ptr, &protoVer, sizeof( protoVer ) );
ptr += sizeof( protoVer );
const auto pnsz = strlen( procname );
memcpy( ptr, procname, pnsz );
ptr += pnsz;
len = ptr - buf;
return buf;
}
#ifdef _WIN32 #ifdef _WIN32
static DWORD s_profilerThreadId = 0; static DWORD s_profilerThreadId = 0;
static char s_crashText[1024]; static char s_crashText[1024];
@ -1091,6 +1108,8 @@ void Profiler::Worker()
} }
} }
const char* broadcastMsg = nullptr;
int broadcastLen = 0;
#ifndef TRACY_NO_BROADCAST #ifndef TRACY_NO_BROADCAST
m_broadcast = (UdpBroadcast*)tracy_malloc( sizeof( UdpBroadcast ) ); m_broadcast = (UdpBroadcast*)tracy_malloc( sizeof( UdpBroadcast ) );
new(m_broadcast) UdpBroadcast(); new(m_broadcast) UdpBroadcast();
@ -1100,6 +1119,10 @@ void Profiler::Worker()
tracy_free( m_broadcast ); tracy_free( m_broadcast );
m_broadcast = nullptr; m_broadcast = nullptr;
} }
else
{
broadcastMsg = GetBroadcastMessage( procname, broadcastLen );
}
#endif #endif
// Connections loop. // Connections loop.
@ -1129,7 +1152,7 @@ void Profiler::Worker()
if( t - m_lastBroadcast > 5000000000 ) // 5s if( t - m_lastBroadcast > 5000000000 ) // 5s
{ {
m_lastBroadcast = t; m_lastBroadcast = t;
m_broadcast->Send( "abc", 3 ); m_broadcast->Send( broadcastMsg, broadcastLen );
auto err = WSAGetLastError(); auto err = WSAGetLastError();
} }
} }