void ApiClient::SendMessage(const Dictionary::Ptr& message)
{
- if (m_WriteQueue.GetLength() > 20000) {
- Log(LogWarning, "remote")
- << "Closing connection for API identity '" << m_Identity << "': Too many queued messages.";
- Disconnect();
- return;
- }
-
m_WriteQueue.Enqueue(boost::bind(&ApiClient::SendMessageSync, ApiClient::Ptr(this), message));
}
}
void ApiClient::Disconnect(void)
-{
- Utility::QueueAsyncCallback(boost::bind(&ApiClient::DisconnectSync, ApiClient::Ptr(this)));
-}
-
-void ApiClient::DisconnectSync(void)
{
Log(LogWarning, "ApiClient")
<< "API client disconnected for identity '" << m_Identity << "'";
} catch (const std::exception&) {
/* Ignore the exception. */
}
+
+ m_WriteQueue.Join();
}
bool ApiClient::ProcessMessage(void)