Dual-Stack AO2 Client to handle both TCP and Websocket connections seemlessly#696
Dual-Stack AO2 Client to handle both TCP and Websocket connections seemlessly#696stonedDiscord merged 15 commits intomasterfrom
Conversation
|
you can still sabotage webAO by using the version check packet |
include/networkmanager.h
Outdated
| AOApplication *ao_app; | ||
| QNetworkAccessManager *http; | ||
| QTcpSocket *server_socket; | ||
| QWebSocket *server_socket; |
There was a problem hiding this comment.
warning: member variable 'server_socket' has public visibility [misc-non-private-member-variables-in-classes]
QWebSocket *server_socket;
^| QTimer *heartbeat_timer; | ||
|
|
||
| const QString DEFAULT_MS_BASEURL = "https://servers.aceattorneyonline.com"; | ||
| const QString DEFAULT_MS_BASEURL = "http://servers.aceattorneyonline.com"; |
There was a problem hiding this comment.
warning: member variable 'DEFAULT_MS_BASEURL' has public visibility [misc-non-private-member-variables-in-classes]
const QString DEFAULT_MS_BASEURL = "http://servers.aceattorneyonline.com";
^
src/networkmanager.cpp
Outdated
| } | ||
|
|
||
| void NetworkManager::handle_server_packet() | ||
| void NetworkManager::handle_server_packet(QString p_data) |
There was a problem hiding this comment.
warning: the parameter 'p_data' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
| void NetworkManager::handle_server_packet(QString p_data) | |
| void NetworkManager::handle_server_packet(const QString& p_data) |
include/networkmanager.h:47:
- void handle_server_packet(QString p_data);
+ void handle_server_packet(const QString& p_data);|
Yeah, but at that point is it even worth it anymore? Just allow WebAO, its not harmful. |
|
Do not remove tcp support or no one will update because their favorite server breaks or they can't play with friends who are not technically inclined. Instead make it connect by websockets first, and if it fails fall back to tcp. Add settings that allow you to disable tcp entirely, and make it off by default. |
Literally what? Name me one of the popular servers that is not CaseCafe or DRO, which has no Websocket support in general and their mostly unique client, that don't have websocket support. This is no harder to set up on the server owner as all major derivatives and servers have WebSocket support which is turned on with a single config change. Adding Websockets as an addition to TCP only adds more clutter to the AOClient with no tangible benefit besides "we backwards compatible because reasons." It already filters for websocket enabled servers so there is no "oh no, can't connect to this server on master" moment. |
|
In the end I can't stop you from doing so, but the endless nemesis of legacy support will eventually make this project less maintainable than it already is, but a long term goal should be to prefer Websocket over TCP and phase the later out. |
|
yeah i know, having legacy things around is the rather unfortunate consequence of a game with such a long history |
"like 5 lines" yeah probably lost a bet.
| void connect_to_server(server_type p_server); | ||
| void disconnect_from_server(); | ||
|
|
||
| public slots: |
There was a problem hiding this comment.
warning: redundant access specifier has the same accessibility as the previous access specifier [readability-redundant-access-specifiers]
| public slots: |
include/networkmanager.h:46: previously declared here
public:
^| switch (p_server.socket_type) { | ||
| case TCP: | ||
| qInfo() << "using TCP backend"; | ||
| server_socket.tcp = new QTcpSocket(this); |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
server_socket.tcp = new QTcpSocket(this);
^| qInfo() << "using TCP backend"; | ||
| server_socket.tcp = new QTcpSocket(this); | ||
|
|
||
| connect(server_socket.tcp, &QAbstractSocket::connected, this, [] { |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
connect(server_socket.tcp, &QAbstractSocket::connected, this, [] {
^| connect(server_socket.tcp, &QAbstractSocket::connected, this, [] { | ||
| qDebug() << "established connection to server"; | ||
| }); | ||
| connect(server_socket.tcp, &QIODevice::readyRead, this, [this] { |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
connect(server_socket.tcp, &QIODevice::readyRead, this, [this] {
^| qDebug() << "established connection to server"; | ||
| }); | ||
| connect(server_socket.tcp, &QIODevice::readyRead, this, [this] { | ||
| handle_server_packet(QString::fromUtf8(server_socket.tcp->readAll())); |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
handle_server_packet(QString::fromUtf8(server_socket.tcp->readAll()));
^| server_socket.tcp->deleteLater(); | ||
| break; | ||
| case WEBSOCKETS: | ||
| server_socket.ws->close(QWebSocketProtocol::CloseCodeGoingAway); |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
server_socket.ws->close(QWebSocketProtocol::CloseCodeGoingAway);
^| break; | ||
| case WEBSOCKETS: | ||
| server_socket.ws->close(QWebSocketProtocol::CloseCodeGoingAway); | ||
| server_socket.ws->deleteLater(); |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
server_socket.ws->deleteLater();
^| server_socket->write(p_packet.toUtf8()); | ||
| switch (active_connection_type) { | ||
| case TCP: | ||
| server_socket.tcp->write(p_packet.toUtf8()); |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
server_socket.tcp->write(p_packet.toUtf8());
^| server_socket.tcp->write(p_packet.toUtf8()); | ||
| break; | ||
| case WEBSOCKETS: | ||
| server_socket.ws->sendTextMessage(p_packet); |
There was a problem hiding this comment.
warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
server_socket.ws->sendTextMessage(p_packet);
^|
oh crap, houston we got a big big problem. need to rebuild the windows qt5 builder so that it includes the websockets module. alternatively remove the gitlab CI for windows altogether |
|
Given that Github Actions produce usable clients, we don't need to run the same CI twice, do we? Though I am sure to be corrected because some people still use 32-bit operating systems in 2022, though. |
|
This completely breaks favourites. Also, I can apparently double click on a favourite entry and it stores my double click and then the next time I click on a server that replies it immediately joins it. |
EDIT: Turns out I've been compiling with minGW while github actions uses VS. stonedDiscord is gonna debug it |
|
It only uses TCP backend when connecting to Favorites servers when built via minGW |
Make "add_favorite_server" remember the socket type
This will keep new entries compatible with 2.9 and prior clients. Makes parsing the list easier too.
* I have no idea what a lookup table is, but this looks close enough
* Otherwise backend selection behaviour is inverted
* Yet it did not do it. Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
|
Should be good to go now. Tested on MingW 32-bit and the CI action. |
oldmud0
left a comment
There was a problem hiding this comment.
this is a major feature for 2.10, so let's get this merged
* Fixes an Omni bug where : would split the servername * Utilises internally QSettings properly for low parsing effort and clear structure * Automatically migrates the legacy serverlist.txt to favorite_servers.ini * Pleases my OCD
| server_type f_server; | ||
| l_favorite_ini.beginGroup(fav_index); | ||
| f_server.ip = l_favorite_ini.value("address", "127.0.0.1").toString(); | ||
| f_server.port = l_favorite_ini.value("port", 27016).toInt(); |
There was a problem hiding this comment.
warning: 27016 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
f_server.port = l_favorite_ini.value("port", 27016).toInt();
^|
Cool. Very cool |
Is this a breaking change? Depends on how you view it.
If you intentionally sabotaged WebAO usage on your server by either limiting what Clients can join trough the websocket or just disabled them, this PR would break any connectivity we would have to that server till they either update or reenable websockets.
The replacement is a nice-to-have, as it finally removes the need for two ports and different connection medias between the regular AO2-Client and WebAO, giving new servers less of a headache implementing both and allowing already existing servers to streamline their connection code.
Closes #739