From c07c414609eb028a0554e5a7f14dbb5531c614b4 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 14 Sep 2024 17:21:27 +0300 Subject: [PATCH] examples/*/network-chat: port to std::chrono intervals Change-Id: Id5ba0f412f1643f6a0588ae69d5bfcb163dc1c81 Reviewed-by: Thiago Macieira --- examples/network/network-chat/connection.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/network/network-chat/connection.cpp b/examples/network/network-chat/connection.cpp index fa4cb812f9e..54d6a60101e 100644 --- a/examples/network/network-chat/connection.cpp +++ b/examples/network/network-chat/connection.cpp @@ -8,9 +8,9 @@ using namespace std::chrono_literals; -static const int TransferTimeout = 30 * 1000; -static const int PongTimeout = 60 * 1000; -static const int PingInterval = 5 * 1000; +static constexpr auto TransferTimeout = 30s; +static constexpr auto PongTimeout = 60s; +static constexpr auto PingInterval = 5s; /* * Protocol is defined as follows, using the CBOR Data Definition Language: @@ -170,12 +170,12 @@ void Connection::processReadyRead() abort(); // parse error if (transferTimer.isActive() && reader.containerDepth() > 1) - transferTimer.start(TransferTimeout * 1ms, this); + transferTimer.start(TransferTimeout, this); } void Connection::sendPing() { - if (pongTime.elapsed() > PongTimeout) { + if (pongTime.durationElapsed() > PongTimeout) { abort(); return; }