diff options
| author | Leifa <26681464+TrickyLeifa@users.noreply.github.com> | 2024-07-09 13:07:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-09 13:07:30 +0200 |
| commit | efd2571459924f40718130f7edd28a72a76b12d7 (patch) | |
| tree | 91751194abb0bfe1306976d676740b43a53dd81b /src/network/websocketconnection.h | |
| parent | 662d4781d2653e02b9f3727a9299ded8c7b1eaa2 (diff) | |
Remove TCP entry point (#1007)
* Remove TCP entry point
Resolve #987
* Remove TCP entry point
* Servers that do not support WebSocket will be marked as `Legacy`
* Removal of TCP connection from the master will follow later.
* Tweaked error message
Diffstat (limited to 'src/network/websocketconnection.h')
| -rw-r--r-- | src/network/websocketconnection.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/network/websocketconnection.h b/src/network/websocketconnection.h new file mode 100644 index 00000000..9df9a49b --- /dev/null +++ b/src/network/websocketconnection.h @@ -0,0 +1,43 @@ +#pragma once + +#include "aopacket.h" +#include "serverinfo.h" + +#include <QObject> +#include <QWebSocket> + +class AOApplication; + +class WebSocketConnection : public QObject +{ + Q_OBJECT + +public: + explicit WebSocketConnection(AOApplication *ao_app, QObject *parent = nullptr); + virtual ~WebSocketConnection(); + + bool isConnected(); + + void connectToServer(const ServerInfo &server); + void disconnectFromServer(); + + void sendPacket(AOPacket packet); + +Q_SIGNALS: + void connectedToServer(); + void disconnectedFromServer(); + void errorOccurred(QString error); + + void receivedPacket(AOPacket packet); + +private: + AOApplication *ao_app; + + QWebSocket *m_socket; + QAbstractSocket::SocketState m_last_state; + +private Q_SLOTS: + void onError(); + void onStateChanged(QAbstractSocket::SocketState state); + void onTextMessageReceived(QString message); +}; |
