Commit f7e918e0 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Reverting try catch around message type reader - also handles network disconnect smoothly.

parent dd5a5358
......@@ -201,8 +201,20 @@ void CVANetMessage::ReadAnswer()
try
{
VANetCompat::sint32 nMessageSize;
int nReturn = m_pConnection->ReadInt32( nMessageSize );
assert( nReturn == sizeof( VANetCompat::sint32 ) );
int nReturn;
try
{
nReturn = m_pConnection->ReadInt32( nMessageSize );
}
catch( ... )
{
nReturn = -1; // Network connection error
}
if( nReturn != sizeof(VANetCompat::sint32) )
{
VA_EXCEPT2( NETWORK_ERROR, "Received less bytes than expected during ReadAnswer of VANetMessage. Payload too long?" );
}
// we need at least the three protocol types
assert( nMessageSize >= 3 * sizeof( VANetCompat::sint32 ) );
......@@ -322,7 +334,8 @@ std::string CVANetMessage::ReadString()
assert( nReturn == sizeof( VANetCompat::sint32 ) );
// Empty string?
if( nSize == 0 ) return "";
if( nSize == 0 )
return "";
std::string sValue;
nReturn = m_oIncoming.ReadString( sValue, nSize );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment