Skip to content

Commit

Permalink
Set receive timestamp after body is read
Browse files Browse the repository at this point in the history
  • Loading branch information
dvsku committed Jun 15, 2024
1 parent 8ade3a3 commit e8022c5
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions include/libnetwrk/net/core/shared/shared_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,20 @@ namespace libnetwrk {

recv_message.head.deserialize(head_buffer);

recv_message.head.recv_timestamp =
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();

if (recv_message.head.data_size == 0) {
ec = {};
co_return;
}

recv_message.data.underlying().resize(recv_message.head.data_size);
if (recv_message.head.data_size != 0) {
recv_message.data.underlying().resize(recv_message.head.data_size);

auto [b_ec, b_size] = co_await m_socket.async_read(recv_message.data);
auto [b_ec, b_size] = co_await m_socket.async_read(recv_message.data);

if (b_ec) {
ec = b_ec;
co_return;
if (b_ec) {
ec = b_ec;
co_return;
}
}

recv_message.head.recv_timestamp =
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();

ec = {};
}

Expand Down

0 comments on commit e8022c5

Please sign in to comment.