mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Add compatibility with previous broadcast versions.
This commit is contained in:
parent
544caef850
commit
86f88714ae
@ -293,18 +293,71 @@ static void DrawContents()
|
|||||||
auto msg = broadcastListen->Read( len, addr, 0 );
|
auto msg = broadcastListen->Read( len, addr, 0 );
|
||||||
if( !msg ) break;
|
if( !msg ) break;
|
||||||
if( len > sizeof( tracy::BroadcastMessage ) ) continue;
|
if( len > sizeof( tracy::BroadcastMessage ) ) continue;
|
||||||
tracy::BroadcastMessage bm;
|
uint16_t broadcastVersion;
|
||||||
memcpy( &bm, msg, len );
|
memcpy( &broadcastVersion, msg, sizeof( uint16_t ) );
|
||||||
|
if( broadcastVersion <= tracy::BroadcastVersion )
|
||||||
if( bm.broadcastVersion == tracy::BroadcastVersion )
|
|
||||||
{
|
{
|
||||||
const uint32_t protoVer = bm.protocolVersion;
|
uint32_t protoVer;
|
||||||
const auto procname = bm.programName;
|
char procname[tracy::WelcomeMessageProgramNameSize];
|
||||||
const auto activeTime = bm.activeTime;
|
int32_t activeTime;
|
||||||
const auto listenPort = bm.listenPort;
|
uint16_t listenPort;
|
||||||
const auto pid = bm.pid;
|
uint64_t pid;
|
||||||
auto address = addr.GetText();
|
|
||||||
|
|
||||||
|
switch( broadcastVersion )
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
tracy::BroadcastMessage bm;
|
||||||
|
memcpy( &bm, msg, len );
|
||||||
|
protoVer = bm.protocolVersion;
|
||||||
|
strcpy( procname, bm.programName );
|
||||||
|
activeTime = bm.activeTime;
|
||||||
|
listenPort = bm.listenPort;
|
||||||
|
pid = bm.pid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
if( len > sizeof( tracy::BroadcastMessage_v2 ) ) continue;
|
||||||
|
tracy::BroadcastMessage_v2 bm;
|
||||||
|
memcpy( &bm, msg, len );
|
||||||
|
protoVer = bm.protocolVersion;
|
||||||
|
strcpy( procname, bm.programName );
|
||||||
|
activeTime = bm.activeTime;
|
||||||
|
listenPort = bm.listenPort;
|
||||||
|
pid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
if( len > sizeof( tracy::BroadcastMessage_v1 ) ) continue;
|
||||||
|
tracy::BroadcastMessage_v1 bm;
|
||||||
|
memcpy( &bm, msg, len );
|
||||||
|
protoVer = bm.protocolVersion;
|
||||||
|
strcpy( procname, bm.programName );
|
||||||
|
activeTime = bm.activeTime;
|
||||||
|
listenPort = bm.listenPort;
|
||||||
|
pid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if( len > sizeof( tracy::BroadcastMessage_v0 ) ) continue;
|
||||||
|
tracy::BroadcastMessage_v0 bm;
|
||||||
|
memcpy( &bm, msg, len );
|
||||||
|
protoVer = bm.protocolVersion;
|
||||||
|
strcpy( procname, bm.programName );
|
||||||
|
activeTime = bm.activeTime;
|
||||||
|
listenPort = 8086;
|
||||||
|
pid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto address = addr.GetText();
|
||||||
const auto ipNumerical = addr.GetNumber();
|
const auto ipNumerical = addr.GetNumber();
|
||||||
const auto clientId = uint64_t( ipNumerical ) | ( uint64_t( listenPort ) << 32 );
|
const auto clientId = uint64_t( ipNumerical ) | ( uint64_t( listenPort ) << 32 );
|
||||||
auto it = clients.find( clientId );
|
auto it = clients.find( clientId );
|
||||||
|
@ -131,7 +131,36 @@ struct BroadcastMessage
|
|||||||
char programName[WelcomeMessageProgramNameSize];
|
char programName[WelcomeMessageProgramNameSize];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BroadcastMessage_v2
|
||||||
|
{
|
||||||
|
uint16_t broadcastVersion;
|
||||||
|
uint16_t listenPort;
|
||||||
|
uint32_t protocolVersion;
|
||||||
|
int32_t activeTime;
|
||||||
|
char programName[WelcomeMessageProgramNameSize];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BroadcastMessage_v1
|
||||||
|
{
|
||||||
|
uint32_t broadcastVersion;
|
||||||
|
uint32_t protocolVersion;
|
||||||
|
uint32_t listenPort;
|
||||||
|
uint32_t activeTime;
|
||||||
|
char programName[WelcomeMessageProgramNameSize];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BroadcastMessage_v0
|
||||||
|
{
|
||||||
|
uint32_t broadcastVersion;
|
||||||
|
uint32_t protocolVersion;
|
||||||
|
uint32_t activeTime;
|
||||||
|
char programName[WelcomeMessageProgramNameSize];
|
||||||
|
};
|
||||||
|
|
||||||
enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
|
enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
|
||||||
|
enum { BroadcastMessageSize_v2 = sizeof( BroadcastMessage_v2 ) };
|
||||||
|
enum { BroadcastMessageSize_v1 = sizeof( BroadcastMessage_v1 ) };
|
||||||
|
enum { BroadcastMessageSize_v0 = sizeof( BroadcastMessage_v0 ) };
|
||||||
|
|
||||||
#pragma pack( pop )
|
#pragma pack( pop )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user