examples/*/network-chat: port to std::chrono intervals
Change-Id: Id5ba0f412f1643f6a0588ae69d5bfcb163dc1c81 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
401a840adb
commit
c07c414609
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
static const int TransferTimeout = 30 * 1000;
|
static constexpr auto TransferTimeout = 30s;
|
||||||
static const int PongTimeout = 60 * 1000;
|
static constexpr auto PongTimeout = 60s;
|
||||||
static const int PingInterval = 5 * 1000;
|
static constexpr auto PingInterval = 5s;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Protocol is defined as follows, using the CBOR Data Definition Language:
|
* Protocol is defined as follows, using the CBOR Data Definition Language:
|
||||||
@ -170,12 +170,12 @@ void Connection::processReadyRead()
|
|||||||
abort(); // parse error
|
abort(); // parse error
|
||||||
|
|
||||||
if (transferTimer.isActive() && reader.containerDepth() > 1)
|
if (transferTimer.isActive() && reader.containerDepth() > 1)
|
||||||
transferTimer.start(TransferTimeout * 1ms, this);
|
transferTimer.start(TransferTimeout, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::sendPing()
|
void Connection::sendPing()
|
||||||
{
|
{
|
||||||
if (pongTime.elapsed() > PongTimeout) {
|
if (pongTime.durationElapsed() > PongTimeout) {
|
||||||
abort();
|
abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user