2 * @file websocketprotocol.h
3 * @brief Contains constants related to the WebSocket standard.
4 * @author Kurt Pattyn (pattyn.kurt@gmail.com)
6 #ifndef QWEBSOCKETPROTOCOL_H
7 #define QWEBSOCKETPROTOCOL_H
13 namespace QWebSocketProtocol
19 //hybi-01, hybi-02 and hybi-03 not supported
29 Version versionFromString(const QString &versionString);
35 CC_PROTOCOL_ERROR = 1002,
36 CC_DATATYPE_NOT_SUPPORTED = 1003,
37 CC_RESERVED_1004 = 1004,
38 CC_MISSING_STATUS_CODE = 1005,
39 CC_ABNORMAL_DISCONNECTION = 1006,
40 CC_WRONG_DATATYPE = 1007,
41 CC_POLICY_VIOLATED = 1008,
42 CC_TOO_MUCH_DATA = 1009,
43 CC_MISSING_EXTENSION = 1010,
44 CC_BAD_OPERATION = 1011,
45 CC_TLS_HANDSHAKE_FAILED = 1015
69 inline bool isOpCodeReserved(OpCode code)
71 return ((code > OC_BINARY) && (code < OC_CLOSE)) || (code > OC_PONG);
73 inline bool isCloseCodeValid(int closeCode)
75 return (closeCode > 999) && (closeCode < 5000) &&
76 (closeCode != CC_RESERVED_1004) && //see RFC6455 7.4.1
77 (closeCode != CC_MISSING_STATUS_CODE) &&
78 (closeCode != CC_ABNORMAL_DISCONNECTION) &&
79 ((closeCode >= 3000) || (closeCode < 1012));
82 void mask(QByteArray *payload, quint32 maskingKey);
83 void mask(char *payload, quint64 size, quint32 maskingKey);
85 inline Version currentVersion() { return V_LATEST; }
87 } //end namespace QWebSocketProtocol
89 #endif // QWEBSOCKETPROTOCOL_H