cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
protocolwebsocket.h
1/*
2 * SPDX-FileCopyrightText: (C) 2017-2019 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef PROTOCOLWEBSOCKET_H
6#define PROTOCOLWEBSOCKET_H
7
8#include "protocol.h"
9
10namespace Cutelyst {
11class Context;
12class Server;
13class ProtocolWebSocket final : public Protocol
14{
15public:
17 virtual ~ProtocolWebSocket() override;
18
19 Type type() const override;
20
21 static QByteArray createWebsocketHeader(quint8 opcode, quint64 len);
22 static QByteArray createWebsocketCloseReply(const QString &msg, quint16 closeCode);
23
24 void parse(Socket *sock, QIODevice *io) const override final;
25
26 ProtocolData *createData(Socket *sock) const override final;
27
28private:
29 bool send_text(Cutelyst::Context *c, Socket *sock, bool singleFrame) const;
30 void send_binary(Cutelyst::Context *c, Socket *sock, bool singleFrame) const;
31 void send_pong(QIODevice *io, const QByteArray data) const;
32 void send_closed(Cutelyst::Context *c, Socket *sock, QIODevice *io) const;
33 bool websocket_parse_header(Socket *sock, const char *buf, QIODevice *io) const;
34 bool websocket_parse_size(Socket *sock, const char *buf, int websockets_max_message_size) const;
35 void websocket_parse_mask(Socket *sock, char *buf, QIODevice *io) const;
36 bool websocket_parse_payload(Socket *sock, char *buf, int len, QIODevice *io) const;
37
38 int m_websockets_max_size;
39};
40
41} // namespace Cutelyst
42
43#endif // PROTOCOLWEBSOCKET_H
The Cutelyst Context.
Definition context.h:42
Implements a web server.
Definition server.h:60
The Cutelyst namespace holds all public Cutelyst API.