Use common function to send server query.

This commit is contained in:
Bartosz Taudul 2017-09-27 02:44:16 +02:00
parent e683a59360
commit 7f865f3517
2 changed files with 15 additions and 12 deletions

View File

@ -214,6 +214,15 @@ void View::DispatchProcess( const QueueItem& ev, const char*& ptr )
} }
} }
void View::ServerQuery( uint8_t type, uint64_t data )
{
enum { DataSize = sizeof( type ) + sizeof( data ) };
char tmp[DataSize];
memcpy( tmp, &type, sizeof( type ) );
memcpy( tmp + sizeof( type ), &data, sizeof( data ) );
m_sock.Send( tmp, DataSize );
}
void View::Process( const QueueItem& ev ) void View::Process( const QueueItem& ev )
{ {
switch( ev.hdr.type ) switch( ev.hdr.type )
@ -322,9 +331,7 @@ void View::CheckString( uint64_t ptr )
m_pendingStrings.emplace( ptr ); m_pendingStrings.emplace( ptr );
uint8_t type = ServerQueryString; ServerQuery( ServerQueryString, ptr );
m_sock.Send( &type, sizeof( type ) );
m_sock.Send( &ptr, sizeof( ptr ) );
} }
void View::CheckThreadString( uint64_t id ) void View::CheckThreadString( uint64_t id )
@ -334,9 +341,7 @@ void View::CheckThreadString( uint64_t id )
m_pendingThreads.emplace( id ); m_pendingThreads.emplace( id );
uint8_t type = ServerQueryThreadString; ServerQuery( ServerQueryThreadString, id );
m_sock.Send( &type, sizeof( type ) );
m_sock.Send( &id, sizeof( id ) );
} }
void View::CheckCustomString( uint64_t ptr, Event* dst ) void View::CheckCustomString( uint64_t ptr, Event* dst )
@ -344,9 +349,7 @@ void View::CheckCustomString( uint64_t ptr, Event* dst )
assert( m_pendingCustomStrings.find( ptr ) == m_pendingCustomStrings.end() ); assert( m_pendingCustomStrings.find( ptr ) == m_pendingCustomStrings.end() );
m_pendingCustomStrings.emplace( ptr, dst ); m_pendingCustomStrings.emplace( ptr, dst );
uint8_t type = ServerQueryCustomString; ServerQuery( ServerQueryCustomString, ptr );
m_sock.Send( &type, sizeof( type ) );
m_sock.Send( &ptr, sizeof( ptr ) );
} }
void View::CheckSourceLocation( uint64_t ptr ) void View::CheckSourceLocation( uint64_t ptr )
@ -356,9 +359,7 @@ void View::CheckSourceLocation( uint64_t ptr )
m_pendingSourceLocation.emplace( ptr ); m_pendingSourceLocation.emplace( ptr );
uint8_t type = ServerQuerySourceLocation; ServerQuery( ServerQuerySourceLocation, ptr );
m_sock.Send( &type, sizeof( type ) );
m_sock.Send( &ptr, sizeof( ptr ) );
} }
void View::AddString( uint64_t ptr, std::string&& str ) void View::AddString( uint64_t ptr, std::string&& str )

View File

@ -46,6 +46,8 @@ private:
void DispatchProcess( const QueueItem& ev ); void DispatchProcess( const QueueItem& ev );
void DispatchProcess( const QueueItem& ev, const char*& ptr ); void DispatchProcess( const QueueItem& ev, const char*& ptr );
void ServerQuery( uint8_t type, uint64_t data );
void Process( const QueueItem& ev ); void Process( const QueueItem& ev );
void ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev ); void ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev );
void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev ); void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );