From 7c07dba3f7b3fc7193da58555d9de0a51d45865b Mon Sep 17 00:00:00 2001
From: Chris Marsh <chris@discordapp.com>
Date: Tue, 25 Jul 2017 11:41:12 -0700
Subject: [PATCH] Handle initial connect failure better.

---
 src/rpc_connection.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rpc_connection.cpp b/src/rpc_connection.cpp
index 8bfef98..b10269b 100644
--- a/src/rpc_connection.cpp
+++ b/src/rpc_connection.cpp
@@ -69,7 +69,7 @@ void RpcConnection::Open()
 
 void RpcConnection::Close()
 {
-    if (onDisconnect && state == State::Connected) {
+    if (onDisconnect && (state == State::Connected || state == State::SentHandshake)) {
         onDisconnect(lastErrorCode, lastErrorMessage);
     }
     connection->Close();