2 QWebSockets implements the WebSocket protocol as defined in RFC 6455.
3 Copyright (C) 2013 Kurt Pattyn (pattyn.kurt@gmail.com)
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef QWEBSOCKETPROTOCOL_H
21 #define QWEBSOCKETPROTOCOL_H
30 namespace QWebSocketProtocol
36 //hybi-01, hybi-02 and hybi-03 not supported
46 Version versionFromString(const QString &versionString);
52 CC_PROTOCOL_ERROR = 1002,
53 CC_DATATYPE_NOT_SUPPORTED = 1003,
54 CC_RESERVED_1004 = 1004,
55 CC_MISSING_STATUS_CODE = 1005,
56 CC_ABNORMAL_DISCONNECTION = 1006,
57 CC_WRONG_DATATYPE = 1007,
58 CC_POLICY_VIOLATED = 1008,
59 CC_TOO_MUCH_DATA = 1009,
60 CC_MISSING_EXTENSION = 1010,
61 CC_BAD_OPERATION = 1011,
62 CC_TLS_HANDSHAKE_FAILED = 1015
86 inline bool isOpCodeReserved(OpCode code)
88 return ((code > OC_BINARY) && (code < OC_CLOSE)) || (code > OC_PONG);
90 inline bool isCloseCodeValid(int closeCode)
92 return (closeCode > 999) && (closeCode < 5000) &&
93 (closeCode != CC_RESERVED_1004) && //see RFC6455 7.4.1
94 (closeCode != CC_MISSING_STATUS_CODE) &&
95 (closeCode != CC_ABNORMAL_DISCONNECTION) &&
96 ((closeCode >= 3000) || (closeCode < 1012));
99 void mask(QByteArray *payload, quint32 maskingKey);
100 void mask(char *payload, quint64 size, quint32 maskingKey);
102 inline Version currentVersion() { return V_LATEST; }
104 } //end namespace QWebSocketProtocol
108 #endif // QWEBSOCKETPROTOCOL_H