Implement keep-alives.

This commit is contained in:
Peter Johnson
2015-09-08 23:15:16 -07:00
parent e1efb7364e
commit 953a2ce807
4 changed files with 20 additions and 8 deletions

View File

@@ -213,7 +213,9 @@ void DispatcherBase::DispatchThreadMain() {
bool reconnect = false;
for (auto& conn : m_connections) {
// post outgoing messages if connection is active
if (conn->state() == NetworkConnection::kActive) conn->PostOutgoing();
// only send keep-alives on client
if (conn->state() == NetworkConnection::kActive)
conn->PostOutgoing(!m_server);
// if client, reconnect if connection died
if (!m_server && conn->state() == NetworkConnection::kDead)