feat(eventsub): reconnect (#6035)
This commit is contained in:
@@ -30,6 +30,10 @@ public:
|
||||
virtual void onNotification(const messages::Metadata &metadata,
|
||||
const boost::json::value &jv) = 0;
|
||||
|
||||
virtual void onClose(
|
||||
std::unique_ptr<Listener> self,
|
||||
const std::optional<std::string> & /* reconnectUrl */) {};
|
||||
|
||||
// Subscription types
|
||||
virtual void onChannelBan(
|
||||
const messages::Metadata &metadata,
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace chatterino::eventsub::lib::payload::session_welcome {
|
||||
/// json_inner=session
|
||||
struct Payload {
|
||||
std::string id;
|
||||
std::optional<std::string> reconnectURL;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/session-welcome.inc"
|
||||
|
||||
@@ -22,20 +22,8 @@ boost::system::error_code handleMessage(
|
||||
std::unique_ptr<Listener> &listener,
|
||||
const boost::beast::flat_buffer &buffer);
|
||||
|
||||
// Sends a WebSocket message and prints the response
|
||||
class Session : public std::enable_shared_from_this<Session>
|
||||
{
|
||||
boost::asio::ip::tcp::resolver resolver;
|
||||
boost::beast::websocket::stream<
|
||||
boost::beast::ssl_stream<boost::beast::tcp_stream>>
|
||||
ws;
|
||||
boost::beast::flat_buffer buffer;
|
||||
std::string host;
|
||||
std::string port;
|
||||
std::string path;
|
||||
std::string userAgent;
|
||||
std::unique_ptr<Listener> listener;
|
||||
|
||||
public:
|
||||
// Resolver and socket require an io_context
|
||||
explicit Session(boost::asio::io_context &ioc,
|
||||
@@ -65,6 +53,19 @@ private:
|
||||
void onRead(boost::beast::error_code ec, std::size_t bytes_transferred);
|
||||
|
||||
void onClose(boost::beast::error_code ec);
|
||||
|
||||
void fail(boost::beast::error_code ec, std::string_view op);
|
||||
|
||||
boost::asio::ip::tcp::resolver resolver;
|
||||
boost::beast::websocket::stream<
|
||||
boost::beast::ssl_stream<boost::beast::tcp_stream>>
|
||||
ws;
|
||||
boost::beast::flat_buffer buffer;
|
||||
std::string host;
|
||||
std::string port;
|
||||
std::string path;
|
||||
std::string userAgent;
|
||||
std::unique_ptr<Listener> listener;
|
||||
};
|
||||
|
||||
} // namespace chatterino::eventsub::lib
|
||||
|
||||
Reference in New Issue
Block a user