23 #ifndef TUFAO_WEBSOCKET_H
24 #define TUFAO_WEBSOCKET_H
26 #include "abstractmessagesocket.h"
29 #include <QtNetwork/QAbstractSocket>
31 #if defined(NO_ERROR) && defined(_WIN32)
32 # define TUFAO_WINERROR_WORKAROUND
40 class HttpServerRequest;
124 PROXY_AUTHENTICATION_REQUIRED,
272 bool connectToHost(
const QHostAddress &address, quint16 port,
273 const QByteArray &resource,
281 bool connectToHost(
const QHostAddress &address,
const QByteArray &resource,
290 bool connectToHost(
const QString &hostname, quint16 port,
291 const QByteArray &resource,
302 bool connectToHost(
const QString &hostname,
const QByteArray &resource,
316 bool connectToHostEncrypted(
const QString &hostname, quint16 port,
317 const QByteArray &resource,
319 const QList<QSslError> &ignoredSslErrors);
324 bool connectToHostEncrypted(
const QString &hostname, quint16 port,
325 const QByteArray &resource,
333 bool connectToHostEncrypted(
const QString &hostname,
334 const QByteArray &resource,
346 bool connectToHostEncrypted(
const QHostAddress &address, quint16 port,
347 const QByteArray &resource,
358 bool connectToHostEncrypted(
const QHostAddress &address,
359 const QByteArray &resource,
402 const QByteArray &head,
445 QString errorString()
const;
455 QHostAddress peerAddress()
const;
465 quint16 peerPort()
const;
471 static QList<QByteArray> supportedProtocols(
const Headers &headers);
485 void pong(QByteArray data);
488 void close()
override;
489 bool sendMessage(
const QByteArray &msg)
override;
498 bool sendBinaryMessage(
const QByteArray &msg);
507 bool sendUtf8Message(
const QByteArray &msg);
518 bool ping(
const QByteArray &data);
521 void onSocketError(QAbstractSocket::SocketError error);
522 void onSslErrors(
const QList<QSslError> &errors);
525 void onDisconnected();
528 void connectToHost(QAbstractSocket *socket,
const QByteArray &resource,
531 bool isResponseOkay();
532 void onClientHandshakeError();
534 void close(quint16 code);
536 void readData(
const QByteArray &data);
541 bool parseMaskingKey();
542 bool parsePayloadData();
544 void decodeFragment(QByteArray &fragment);
545 void evaluateControlFrame();
553 #if defined(TUFAO_WINERROR_WORKAROUND)
555 # undef TUFAO_WINERROR_WORKAROUND
558 #endif // TUFAO_WEBSOCKET_H
This class represents a WebSocket connection.
Definition: websocket.h:235
See QAbstractSocket::HostNotFoundError.
See QAbstractSocket::RemoteHostClosedError.
WebSocketError
This enum describes the possible erros tha can occur.
Definition: websocket.h:56
See QAbstractSocket::ProxyConnectionRefusedError.
The Tufao::HttpServer represents a HTTP request received by Tufao::HttpServer.
Definition: httpserverrequest.h:54
See QAbstractSocket::ProxyConnectionClosedError.
See QAbstractSocket::SocketTimeoutError.
WebSocketMessageType
This enum represents the possible message's types that WebSocket supports.
Definition: websocket.h:194
See QAbstractSocket::SslHandshakeFailedError.
See QAbstractSocket::ConnectionRefusedError.
The Tufao::AbstractMessageSocket class represents a socket that sends and receives messages...
Definition: abstractmessagesocket.h:50
This is the namespace where all Tufão facilities are grouped.
Definition: abstracthttpserverrequesthandler.h:30
See QAbstractSocket::SocketAccessError.
See QAbstractSocket::ProxyProtocolError.
It occurs when the remote peer (or an intermediary) violates the WebSocket protocol.
See QAbstractSocket::SocketResourceError.
It occurs when the server doesn't support WebSocket for the resource asked for (or for any resource a...
See QAbstractSocket::ProxyConnectionTimeoutError.
See QAbstractSocket::ProxyNotFoundError.
See QAbstractSocket::NetworkError.
See QAbstractSocket::UnsupportedSocketOperationError.