ws_decoder.hpp
Go to the documentation of this file.
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  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;
48  unsigned char _mask[4];
49 
50  ZMQ_NON_COPYABLE_NOR_MOVABLE (ws_decoder_t)
51 };
52 }
53 
54 #endif
decoder_allocators.hpp
zmq::ZMQ_FINAL::_size
uint64_t _size
Definition: ws_decoder.hpp:46
zmq
Definition: zmq.hpp:229
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
zmq::ZMQ_FINAL::msg
msg_t * msg()
Definition: ws_decoder.hpp:26
decoder.hpp
zmq::ZMQ_FINAL::_must_mask
const bool _must_mask
Definition: ws_decoder.hpp:45
zmq::ws_protocol_t::opcode_t
opcode_t
Definition: ws_protocol.hpp:13
zmq::ZMQ_FINAL::_opcode
zmq::ws_protocol_t::opcode_t _opcode
Definition: ws_decoder.hpp:47
ws_protocol.hpp
ZMQ_FINAL
Definition: unittest_ip_resolver.cpp:26
zmq::msg_t
Definition: msg.hpp:33


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:02