From 929ebf1a6008d861473e3ceffd11cd4eca90d620 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 15 Nov 2022 02:14:49 -0500 Subject: mess with some websocket stuff to try and fix things to be honest, im not sure what ive done here. whatever memory i have of the issue i was trying to fix has long disappeared by the time im committing this. theres still some issues with being force disconnected and i really dont understand it ill figure it out eventually... maybe :/ --- src/discord/voiceclient.hpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/discord/voiceclient.hpp') diff --git a/src/discord/voiceclient.hpp b/src/discord/voiceclient.hpp index 1d8b952..61b329c 100644 --- a/src/discord/voiceclient.hpp +++ b/src/discord/voiceclient.hpp @@ -15,6 +15,7 @@ // clang-format on enum class VoiceGatewayCloseCode : uint16_t { + Normal = 4000, UnknownOpcode = 4001, InvalidPayload = 4002, NotAuthenticated = 4003, @@ -228,7 +229,10 @@ private: std::array m_secret_key; - Websocket m_ws; + // this is a unique_ptr because Websocket/ixwebsocket seems to have some strange behavior + // and quite frankly i do not feel like figuring out what is wrong + // so using a unique_ptr will just let me nuke the whole thing and make a new one + std::unique_ptr m_ws; UDPSocket m_udp; Glib::Dispatcher m_dispatcher; @@ -246,6 +250,24 @@ private: std::atomic m_connected = false; + enum class State { + Opening, + Opened, + ClosingByClient, + ClosedByClient, + ClosingByServer, + ClosedByServer, + }; + + void SetState(State state); + + [[nodiscard]] bool IsOpening() const noexcept; + [[nodiscard]] bool IsOpened() const noexcept; + [[nodiscard]] bool IsClosing() const noexcept; + [[nodiscard]] bool IsClosed() const noexcept; + + std::atomic m_state; + using type_signal_connected = sigc::signal; using type_signal_disconnected = sigc::signal; using type_signal_speaking = sigc::signal; -- cgit v1.2.3