JsonRpcConnection#Send*Message(): keep this alive

This commit is contained in:
Alexander A. Klimov 2020-02-17 16:12:07 +01:00
parent e9b8fc234b
commit fbce756007
1 changed files with 6 additions and 2 deletions

View File

@ -170,12 +170,16 @@ ConnectionRole JsonRpcConnection::GetRole() const
void JsonRpcConnection::SendMessage(const Dictionary::Ptr& message)
{
m_IoStrand.post([this, message]() { SendMessageInternal(message); });
Ptr keepAlive (this);
m_IoStrand.post([this, keepAlive, message]() { SendMessageInternal(message); });
}
void JsonRpcConnection::SendRawMessage(const String& message)
{
m_IoStrand.post([this, message]() {
Ptr keepAlive (this);
m_IoStrand.post([this, keepAlive, message]() {
m_OutgoingMessagesQueue.emplace_back(message);
m_OutgoingMessagesQueued.Set();
});