summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-04-12 03:03:18 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-04-12 03:03:18 -0400
commitceaf4649dc317e248d0b0df6cf78c1798f287e1a (patch)
treeccac839522961d5f9fdad58fc9795b34566ec584
parent4af7dacb0f5289145edab4c4a9f8d69917a050d6 (diff)
downloadabaddon-portaudio-ceaf4649dc317e248d0b0df6cf78c1798f287e1a.tar.gz
abaddon-portaudio-ceaf4649dc317e248d0b0df6cf78c1798f287e1a.zip
show dialog on unexpected socket close code
-rw-r--r--abaddon.cpp7
-rw-r--r--discord/objects.hpp17
2 files changed, 24 insertions, 0 deletions
diff --git a/abaddon.cpp b/abaddon.cpp
index 2123dbd..93fce4c 100644
--- a/abaddon.cpp
+++ b/abaddon.cpp
@@ -240,6 +240,13 @@ void Abaddon::DiscordOnDisconnect(bool is_reconnecting, GatewayCloseCode close_c
m_main_window->UpdateComponents();
if (close_code == GatewayCloseCode::AuthenticationFailed) {
Gtk::MessageDialog dlg(*m_main_window, "Discord rejected your token", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
+ dlg.set_position(Gtk::WIN_POS_CENTER);
+ dlg.run();
+ } else if (close_code != GatewayCloseCode::Normal) {
+ Gtk::MessageDialog dlg(*m_main_window,
+ "Lost connection with Discord's gateway. Try reconnecting (code " + std::to_string(static_cast<unsigned>(close_code)) + ")",
+ false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
+ dlg.set_position(Gtk::WIN_POS_CENTER);
dlg.run();
}
}
diff --git a/discord/objects.hpp b/discord/objects.hpp
index 0f5c437..d236736 100644
--- a/discord/objects.hpp
+++ b/discord/objects.hpp
@@ -71,6 +71,23 @@ enum class GatewayEvent : int {
};
enum class GatewayCloseCode : uint16_t {
+ // standard
+ Normal = 1000,
+ GoingAway = 1001,
+ ProtocolError = 1002,
+ Unsupported = 1003,
+ NoStatus = 1005,
+ Abnormal = 1006,
+ UnsupportedPayload = 1007,
+ PolicyViolation = 1008,
+ TooLarge = 1009,
+ MandatoryExtension = 1010,
+ ServerError = 1011,
+ ServiceRestart = 1012,
+ TryAgainLater = 1013,
+ BadGateway = 1014,
+ TLSHandshakeFailed = 1015,
+
// discord
UnknownError = 4000,
UnknownOpcode = 4001,