-
-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(plugins): add c2.WebSocket
#6076
base: master
Are you sure you want to change the base?
Conversation
How did you decide on the TLS requirement? It seems weird to not be able to connect to another local program. |
Because of Boost.Beast and that you need to statically declare the types of streams. It's not super hard to add non-TLS streams. I could do it later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 25 out of 27. Check the log or trigger a new build to see more.
Added. |
@@ -3,16 +3,16 @@ freebsd_instance: | |||
|
|||
task: | |||
install_script: | |||
- pkg install -y boost-libs git libnotify qt6-base qt6-svg qt6-5compat qt6-imageformats qtkeychain-qt6 cmake pkgconf | |||
- pkg install -y llvm19-lite boost-libs git libnotify qt6-base qt6-svg qt6-5compat qt6-imageformats qtkeychain-qt6 cmake pkgconf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because of https://redirect.github.com/ThePhD/sol2/issues/1581. Builds with Clang 18 fail. 17 and 19 both work.
@@ -1,6 +1,6 @@ | |||
/** @noSelfInFile */ | |||
|
|||
declare module c2 { | |||
declare namespace c2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand the docs correctly, then we have to use namespace
here instead of module
.
@@ -74,6 +77,7 @@ class PluginController | |||
static void loadChatterinoLib(lua_State *l); | |||
bool tryLoadFromDir(const QDir &pluginDir); | |||
std::map<QString, std::unique_ptr<Plugin>> plugins_; | |||
WebSocketPool webSocketPool_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently scoped to the controller but could technically be global to the app.
@@ -89,7 +89,7 @@ QByteArray sol_lua_get(sol::types<QByteArray>, lua_State *L, int index, | |||
sol::stack::record &tracking) | |||
{ | |||
auto str = sol::stack::get<std::string_view>(L, index, tracking); | |||
return QByteArray::fromRawData(str.data(), str.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fromRawData
creates a view over the data (it doesn't copy) and is suspect to dangling references. We should use QByteArrayView
for this.
@@ -9,50 +9,48 @@ namespace chatterino { | |||
// Taken from | |||
// https://stackoverflow.com/questions/21646467/how-to-execute-a-functor-or-a-lambda-in-a-given-thread-in-qt-gcd-style | |||
// Qt 5/4 - preferred, has least allocations | |||
template <typename F> | |||
static void postToThread(F &&fun, QObject *obj = QCoreApplication::instance()) | |||
static void postToThread(auto &&f, QObject *obj = QCoreApplication::instance()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now accepts non-copyable functions (e.g. lambdas with std::unique_ptr
captures).
Adds a small WebSocket client. Connections must use TLS.
Example
Go in a Twitch channel and run
/mirror-chat
. All chat messages will now appear twice.Requests: #4931, #4999 (comment)