/src/libzmq/src/ws_decoder.hpp
Line | Count | Source |
1 | | /* SPDX-License-Identifier: MPL-2.0 */ |
2 | | |
3 | | #ifndef __ZMQ_WS_DECODER_HPP_INCLUDED__ |
4 | | #define __ZMQ_WS_DECODER_HPP_INCLUDED__ |
5 | | |
6 | | #include "decoder.hpp" |
7 | | #include "decoder_allocators.hpp" |
8 | | #include "ws_protocol.hpp" |
9 | | |
10 | | namespace zmq |
11 | | { |
12 | | // Decoder for Web socket framing protocol. Converts data stream into messages. |
13 | | // The class has to inherit from shared_message_memory_allocator because |
14 | | // the base class calls allocate in its constructor. |
15 | | class ws_decoder_t ZMQ_FINAL |
16 | | : public decoder_base_t<ws_decoder_t, shared_message_memory_allocator> |
17 | | { |
18 | | public: |
19 | | ws_decoder_t (size_t bufsize_, |
20 | | int64_t maxmsgsize_, |
21 | | bool zero_copy_, |
22 | | bool must_mask_); |
23 | | ~ws_decoder_t (); |
24 | | |
25 | | // i_decoder interface. |
26 | 0 | msg_t *msg () { return &_in_progress; } |
27 | | |
28 | | private: |
29 | | int opcode_ready (unsigned char const *); |
30 | | int size_first_byte_ready (unsigned char const *); |
31 | | int short_size_ready (unsigned char const *); |
32 | | int long_size_ready (unsigned char const *); |
33 | | int mask_ready (unsigned char const *); |
34 | | int flags_ready (unsigned char const *); |
35 | | int message_ready (unsigned char const *); |
36 | | |
37 | | int size_ready (unsigned char const *); |
38 | | |
39 | | unsigned char _tmpbuf[8]; |
40 | | unsigned char _msg_flags; |
41 | | msg_t _in_progress; |
42 | | |
43 | | const bool _zero_copy; |
44 | | const int64_t _max_msg_size; |
45 | | const bool _must_mask; |
46 | | uint64_t _size; |
47 | | zmq::ws_protocol_t::opcode_t _opcode; |
48 | | unsigned char _mask[4]; |
49 | | |
50 | | ZMQ_NON_COPYABLE_NOR_MOVABLE (ws_decoder_t) |
51 | | }; |
52 | | } |
53 | | |
54 | | #endif |