MythTV  master
mythwebsockettypes.h
Go to the documentation of this file.
1 #ifndef MYTHWEBSOCKETTYPES_H
2 #define MYTHWEBSOCKETTYPES_H
3 
4 // Std
5 #include <deque>
6 
7 // Qt
8 #include <QString>
9 
10 // MythTV
12 
14 {
23  WSOpClose = 0x8,
24  WSOpPing = 0x9,
25  WSOpPong = 0xA,
31 };
32 
34 {
35  WSCloseNormal = 1000,
42  WSClosePolicy = 1008,
46  WSCloseNoTLS = 1012,
48 };
49 
50 using WSQueue = std::deque<DataPayload>;
51 
52 class MythWebSocketFrame;
53 using WSFrame = std::shared_ptr<MythWebSocketFrame>;
54 
56 {
57  public:
58  static WSFrame CreateFrame(const QByteArray& Header);
59 
60  bool m_invalid { false };
62  uint64_t m_length { 0 };
63  bool m_final { false };
64  bool m_masked { false };
65  QByteArray m_mask;
66  DataPayload m_payload { nullptr };
67 
68  protected:
69  MythWebSocketFrame(bool Invalid, WSOpCode Code, bool Final, bool Masked, uint64_t Length);
70 };
71 
72 
73 class MythWS
74 {
75  public:
76  static QString OpCodeToString (WSOpCode Code);
78  static bool UseRawTextForProtocol (MythSocketProtocol Protocol);
79  static inline bool OpCodeIsValid (WSOpCode Code)
80  {
81  return Code == WSOpContinuation || Code == WSOpTextFrame ||
82  Code == WSOpBinaryFrame || Code == WSOpClose ||
83  Code == WSOpPing || Code == WSOpPong;
84  }
85 };
86 
87 #endif
WSOpPong
@ WSOpPong
Definition: mythwebsockettypes.h:25
WSCloseTooLarge
@ WSCloseTooLarge
Definition: mythwebsockettypes.h:43
WSCloseNormal
@ WSCloseNormal
Definition: mythwebsockettypes.h:35
WSCloseProtocolError
@ WSCloseProtocolError
Definition: mythwebsockettypes.h:37
WSCloseNoStatus
@ WSCloseNoStatus
Definition: mythwebsockettypes.h:39
WSOpReserved6
@ WSOpReserved6
Definition: mythwebsockettypes.h:21
WSOpBinaryFrame
@ WSOpBinaryFrame
Definition: mythwebsockettypes.h:17
WSOpContinuation
@ WSOpContinuation
Definition: mythwebsockettypes.h:15
WSFrame
std::shared_ptr< MythWebSocketFrame > WSFrame
Definition: mythwebsockettypes.h:53
WSCloseGoingAway
@ WSCloseGoingAway
Definition: mythwebsockettypes.h:36
MythWS::FrameFormatForProtocol
static WSOpCode FrameFormatForProtocol(MythSocketProtocol Protocol)
Definition: mythwebsockettypes.cpp:45
WSQueue
std::deque< DataPayload > WSQueue
Definition: mythwebsockettypes.h:50
MythWebSocketFrame::m_final
bool m_final
Definition: mythwebsockettypes.h:63
WSOpReserved5
@ WSOpReserved5
Definition: mythwebsockettypes.h:20
WSOpReservedF
@ WSOpReservedF
Definition: mythwebsockettypes.h:30
MythWebSocketFrame::m_mask
QByteArray m_mask
Definition: mythwebsockettypes.h:65
MythWebSocketFrame::m_masked
bool m_masked
Definition: mythwebsockettypes.h:64
mythhttpcommon.h
MythSocketProtocol
MythSocketProtocol
Definition: mythhttpcommon.h:25
MythWebSocketFrame::m_payload
DataPayload m_payload
Definition: mythwebsockettypes.h:66
WSCloseUnexpectedErr
@ WSCloseUnexpectedErr
Definition: mythwebsockettypes.h:45
MythWebSocketFrame::m_length
uint64_t m_length
Definition: mythwebsockettypes.h:62
WSOpPing
@ WSOpPing
Definition: mythwebsockettypes.h:24
WSCloseUnsupported
@ WSCloseUnsupported
Definition: mythwebsockettypes.h:38
WSOpReservedC
@ WSOpReservedC
Definition: mythwebsockettypes.h:27
DataPayload
std::shared_ptr< MythSharedData > DataPayload
Definition: mythhttpcommon.h:36
WSOpCode
WSOpCode
Definition: mythwebsockettypes.h:13
WSCloseNoTLS
@ WSCloseNoTLS
Definition: mythwebsockettypes.h:46
WSOpReservedD
@ WSOpReservedD
Definition: mythwebsockettypes.h:28
WSOpTextFrame
@ WSOpTextFrame
Definition: mythwebsockettypes.h:16
MythWS::OpCodeIsValid
static bool OpCodeIsValid(WSOpCode Code)
Definition: mythwebsockettypes.h:79
WSErrorCode
WSErrorCode
Definition: mythwebsockettypes.h:33
WSCloseBadData
@ WSCloseBadData
Definition: mythwebsockettypes.h:41
MythWebSocketFrame::m_opCode
WSOpCode m_opCode
Definition: mythwebsockettypes.h:61
MythWS
Definition: mythwebsockettypes.h:73
WSOpReserved7
@ WSOpReserved7
Definition: mythwebsockettypes.h:22
WSOpReservedB
@ WSOpReservedB
Definition: mythwebsockettypes.h:26
WSClosePolicy
@ WSClosePolicy
Definition: mythwebsockettypes.h:42
WSOpReserved4
@ WSOpReserved4
Definition: mythwebsockettypes.h:19
WSOpClose
@ WSOpClose
Definition: mythwebsockettypes.h:23
WSCloseTLSHandshakeError
@ WSCloseTLSHandshakeError
Definition: mythwebsockettypes.h:47
MythWebSocketFrame::MythWebSocketFrame
MythWebSocketFrame(bool Invalid, WSOpCode Code, bool Final, bool Masked, uint64_t Length)
Definition: mythwebsockettypes.cpp:20
WSCloseNoExtensions
@ WSCloseNoExtensions
Definition: mythwebsockettypes.h:44
WSOpReservedE
@ WSOpReservedE
Definition: mythwebsockettypes.h:29
MythWS::OpCodeToString
static QString OpCodeToString(WSOpCode Code)
Definition: mythwebsockettypes.cpp:30
MythWebSocketFrame
Definition: mythwebsockettypes.h:55
MythWebSocketFrame::CreateFrame
static WSFrame CreateFrame(const QByteArray &Header)
Definition: mythwebsockettypes.cpp:7
MythWebSocketFrame::m_invalid
bool m_invalid
Definition: mythwebsockettypes.h:60
MythWS::UseRawTextForProtocol
static bool UseRawTextForProtocol(MythSocketProtocol Protocol)
Definition: mythwebsockettypes.cpp:58
WSOpReserved3
@ WSOpReserved3
Definition: mythwebsockettypes.h:18
WSCloseAbnormal
@ WSCloseAbnormal
Definition: mythwebsockettypes.h:40