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;
266 bool connectToHost(
const QHostAddress &address, quint16 port,
267 const QByteArray &resource,
275 bool connectToHost(
const QHostAddress &address,
const QByteArray &resource,
284 bool connectToHost(
const QString &hostname, quint16 port,
285 const QByteArray &resource,
296 bool connectToHost(
const QString &hostname,
const QByteArray &resource,
310 bool connectToHostEncrypted(
const QString &hostname, quint16 port,
311 const QByteArray &resource,
313 const QList<QSslError> &ignoredSslErrors);
318 bool connectToHostEncrypted(
const QString &hostname, quint16 port,
319 const QByteArray &resource,
327 bool connectToHostEncrypted(
const QString &hostname,
328 const QByteArray &resource,
340 bool connectToHostEncrypted(
const QHostAddress &address, quint16 port,
341 const QByteArray &resource,
352 bool connectToHostEncrypted(
const QHostAddress &address,
353 const QByteArray &resource,
393 const QByteArray &head,
406 void setMessagesType(MessageType type);
415 MessageType messagesType()
const;
425 QString errorString()
const;
435 QHostAddress peerAddress()
const;
445 quint16 peerPort()
const;
451 static QList<QByteArray> supportedProtocols(
const Headers &headers);
465 void pong(QByteArray data);
469 bool sendMessage(
const QByteArray &msg);
478 bool sendBinaryMessage(
const QByteArray &msg);
487 bool sendUtf8Message(
const QByteArray &msg);
498 bool ping(
const QByteArray &data);
501 void onSocketError(QAbstractSocket::SocketError error);
502 void onSslErrors(
const QList<QSslError> &errors);
505 void onDisconnected();
508 void connectToHost(QAbstractSocket *socket,
const QByteArray &resource,
511 bool isResponseOkay();
512 void onClientHandshakeError();
514 void close(quint16 code);
516 void readData(
const QByteArray &data);
521 bool parseMaskingKey();
522 bool parsePayloadData();
524 void decodeFragment(QByteArray &fragment);
525 void evaluateControlFrame();
533 #if defined(TUFAO_WINERROR_WORKAROUND)
535 # undef TUFAO_WINERROR_WORKAROUND
538 #endif // TUFAO_WEBSOCKET_H
See QAbstractSocket::ProxyNotFoundError.
Definition: websocket.h:189
See QAbstractSocket::ProxyConnectionTimeoutError.
Definition: websocket.h:182
This class represents a WebSocket connection.
Definition: websocket.h:71
See QAbstractSocket::HostNotFoundError.
Definition: websocket.h:112
UTF8 messages.
Definition: websocket.h:226
See QAbstractSocket::SocketAccessError.
Definition: websocket.h:119
The Tufao::HttpServer represents a HTTP request received by Tufao::HttpServer.
Definition: httpserverrequest.h:47
See QAbstractSocket::SocketTimeoutError.
Definition: websocket.h:133
Error
This enum describes the possible erros tha can occur.
Definition: websocket.h:86
See QAbstractSocket::UnsupportedSocketOperationError.
Definition: websocket.h:147
See QAbstractSocket::ProxyAuthenticationRequiredError.
Definition: websocket.h:154
It occurs when the server doesn't support WebSocket for the resource asked for (or for any resource a...
Definition: websocket.h:204
MessageType
This enum represents the possible message's types that WebSocket supports.
Definition: websocket.h:221
See QAbstractSocket::ProxyProtocolError.
Definition: websocket.h:196
See QAbstractSocket::NetworkError.
Definition: websocket.h:140
See QAbstractSocket::SslHandshakeFailedError.
Definition: websocket.h:161
The Tufao::AbstractMessageSocket class represents a socket that sends and receives messages...
Definition: abstractmessagesocket.h:50
See QAbstractSocket::ProxyConnectionClosedError.
Definition: websocket.h:175
See QAbstractSocket::ProxyConnectionRefusedError.
Definition: websocket.h:168
See QAbstractSocket::SocketResourceError.
Definition: websocket.h:126
See QAbstractSocket::ConnectionRefusedError.
Definition: websocket.h:98
It occurs when the remote peer (or an intermediary) violates the WebSocket protocol.
Definition: websocket.h:209
See QAbstractSocket::RemoteHostClosedError.
Definition: websocket.h:105