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
19 #ifndef QWEBSOCKETPROTOCOL_H
20 #define QWEBSOCKETPROTOCOL_H
29 namespace QWebSocketProtocol
35 //hybi-01, hybi-02 and hybi-03 not supported
45 Version versionFromString(const QString &versionString);
51 CC_PROTOCOL_ERROR = 1002,
52 CC_DATATYPE_NOT_SUPPORTED = 1003,
53 CC_RESERVED_1004 = 1004,
54 CC_MISSING_STATUS_CODE = 1005,
55 CC_ABNORMAL_DISCONNECTION = 1006,
56 CC_WRONG_DATATYPE = 1007,
57 CC_POLICY_VIOLATED = 1008,
58 CC_TOO_MUCH_DATA = 1009,
59 CC_MISSING_EXTENSION = 1010,
60 CC_BAD_OPERATION = 1011,
61 CC_TLS_HANDSHAKE_FAILED = 1015
85 inline bool isOpCodeReserved(OpCode code)
87 return ((code > OC_BINARY) && (code < OC_CLOSE)) || (code > OC_PONG);
89 inline bool isCloseCodeValid(int closeCode)
91 return (closeCode > 999) && (closeCode < 5000) &&
92 (closeCode != CC_RESERVED_1004) && //see RFC6455 7.4.1
93 (closeCode != CC_MISSING_STATUS_CODE) &&
94 (closeCode != CC_ABNORMAL_DISCONNECTION) &&
95 ((closeCode >= 3000) || (closeCode < 1012));
98 void mask(QByteArray *payload, quint32 maskingKey);
99 void mask(char *payload, quint64 size, quint32 maskingKey);
101 inline Version currentVersion() { return V_LATEST; }
103 } //end namespace QWebSocketProtocol
107 #endif // QWEBSOCKETPROTOCOL_H