Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
VANet
Commits
f7e918e0
Commit
f7e918e0
authored
Jan 24, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Reverting try catch around message type reader - also handles network disconnect smoothly.
parent
dd5a5358
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/VANetMessage.cpp
View file @
f7e918e0
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment