feat(eventsub): reconnect (#6035)

This commit is contained in:
nerix
2025-03-06 22:41:35 +01:00
committed by GitHub
parent 9d1f930e85
commit 914257d537
18 changed files with 305 additions and 45 deletions
+16
View File
@@ -140,6 +140,12 @@ Args::Args(const QApplication &app, const Paths &paths)
"specified, Twitch is assumed.",
"t:channel");
#ifndef NDEBUG
QCommandLineOption useLocalEventsubOption(
"use-local-eventsub",
"Use the local eventsub server at 127.0.0.1:3012.");
#endif
parser.addOptions({
{{"V", "version"}, "Displays version information."},
crashRecoveryOption,
@@ -152,6 +158,9 @@ Args::Args(const QApplication &app, const Paths &paths)
loginOption,
channelLayout,
activateOption,
#ifndef NDEBUG
useLocalEventsubOption,
#endif
});
if (!parser.parse(app.arguments()))
@@ -216,6 +225,13 @@ Args::Args(const QApplication &app, const Paths &paths)
parseActivateOption(parser.value(activateOption));
}
#ifndef NDEBUG
if (parser.isSet(useLocalEventsubOption))
{
this->useLocalEventsub = true;
}
#endif
this->currentArguments_ = extractCommandLine(parser, {
verboseOption,
safeModeOption,
+5
View File
@@ -64,6 +64,11 @@ public:
bool verbose{};
bool safeMode{};
#ifndef NDEBUG
// twitch event websocket start-server --ssl --port 3012
bool useLocalEventsub = false;
#endif
QStringList currentArguments() const;
private:
+3
View File
@@ -53,6 +53,9 @@ public:
/// By default, there's no explicit timeout for the request.
/// To set a timeout, use NetworkRequest's timeout method
std::optional<std::chrono::milliseconds> timeout{};
#ifndef NDEBUG
bool ignoreSslErrors = false; // for local eventsub
#endif
QString getHash();
+8
View File
@@ -215,4 +215,12 @@ NetworkRequest NetworkRequest::json(const QByteArray &payload) &&
.header("Accept", "application/json");
}
#ifndef NDEBUG
NetworkRequest NetworkRequest::ignoreSslErrors(bool ignore) &&
{
this->data->ignoreSslErrors = ignore;
return std::move(*this);
}
#endif
} // namespace chatterino
+4
View File
@@ -76,6 +76,10 @@ public:
NetworkRequest json(const QJsonDocument &document) &&;
NetworkRequest json(const QByteArray &payload) &&;
#ifndef NDEBUG
NetworkRequest ignoreSslErrors(bool ignore) &&;
#endif
void execute();
private:
+10
View File
@@ -61,6 +61,16 @@ void NetworkTask::run()
QObject::connect(this->reply_, &QNetworkReply::finished, this,
&NetworkTask::finished);
#ifndef NDEBUG
if (this->data_->ignoreSslErrors)
{
QObject::connect(this->reply_, &QNetworkReply::sslErrors, this,
[this](const auto &errors) {
this->reply_->ignoreSslErrors(errors);
});
}
#endif
}
QNetworkReply *NetworkTask::createReply()