diff options
| author | Osmium Sorcerer <os@sof.beauty> | 2026-03-22 18:56:58 +0000 |
|---|---|---|
| committer | Osmium Sorcerer <os@sof.beauty> | 2026-03-29 22:22:25 +0000 |
| commit | d6352bc889638b82a887e0a1a138f2b8086dbbdb (patch) | |
| tree | 35f7bb8b5b6641f69930bd8485260bc8594e5fe9 /src/network/websocketconnection.cpp | |
| parent | a124f46861d549ddc13485536962e34d80de939a (diff) | |
Handle extension packets using binary frames
The subprotocol shall use binary frames, and AO protocol stays separated
within the text frames.
Diffstat (limited to 'src/network/websocketconnection.cpp')
| -rw-r--r-- | src/network/websocketconnection.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/network/websocketconnection.cpp b/src/network/websocketconnection.cpp index d51cdca..fedbe11 100644 --- a/src/network/websocketconnection.cpp +++ b/src/network/websocketconnection.cpp @@ -14,6 +14,7 @@ WebSocketConnection::WebSocketConnection(AOApplication *ao_app, QObject *parent) connect(m_socket, &QWebSocket::errorOccurred, this, &WebSocketConnection::onError); connect(m_socket, &QWebSocket::stateChanged, this, &WebSocketConnection::onStateChanged); connect(m_socket, &QWebSocket::textMessageReceived, this, &WebSocketConnection::onTextMessageReceived); + connect(m_socket, &QWebSocket::binaryMessageReceived, this, &WebSocketConnection::onBinaryMessageReceived); } WebSocketConnection::~WebSocketConnection() @@ -55,6 +56,11 @@ void WebSocketConnection::sendPacket(AOPacket packet) m_socket->sendTextMessage(packet.toString(true)); } +void WebSocketConnection::sendExMessage(const QByteArray &msg) +{ + m_socket->sendBinaryMessage(msg); +} + void WebSocketConnection::onError() { Q_EMIT errorOccurred(m_socket->errorString()); @@ -95,3 +101,13 @@ void WebSocketConnection::onTextMessageReceived(QString message) Q_EMIT receivedPacket(AOPacket(header, raw_content)); } + +void WebSocketConnection::onBinaryMessageReceived(const QByteArray message) +{ + if (message.isEmpty()) + { + return; + } + + Q_EMIT receivedExMessage(message); +} |
