MythTV
master
libs
libmythbase
http
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
11
#include "
libmythbase/http/mythhttpcommon.h
"
12
13
enum
WSOpCode
14
{
15
WSOpContinuation
= 0x0,
16
WSOpTextFrame
= 0x1,
17
WSOpBinaryFrame
= 0x2,
18
WSOpReserved3
= 0x3,
19
WSOpReserved4
= 0x4,
20
WSOpReserved5
= 0x5,
21
WSOpReserved6
= 0x6,
22
WSOpReserved7
= 0x7,
23
WSOpClose
= 0x8,
24
WSOpPing
= 0x9,
25
WSOpPong
= 0xA,
26
WSOpReservedB
= 0xB,
27
WSOpReservedC
= 0xC,
28
WSOpReservedD
= 0xD,
29
WSOpReservedE
= 0xE,
30
WSOpReservedF
= 0xF
31
};
32
33
enum
WSErrorCode
34
{
35
WSCloseNormal
= 1000,
36
WSCloseGoingAway
= 1001,
37
WSCloseProtocolError
= 1002,
38
WSCloseUnsupported
= 1003,
39
WSCloseNoStatus
= 1005,
40
WSCloseAbnormal
= 1006,
41
WSCloseBadData
= 1007,
42
WSClosePolicy
= 1008,
43
WSCloseTooLarge
= 1009,
44
WSCloseNoExtensions
= 1010,
45
WSCloseUnexpectedErr
= 1011,
46
WSCloseNoTLS
= 1012,
47
WSCloseTLSHandshakeError
= 1015
48
};
49
50
using
WSQueue
= std::deque<DataPayload>;
51
52
class
MythWebSocketFrame
;
53
using
WSFrame
= std::shared_ptr<MythWebSocketFrame>;
54
55
class
MythWebSocketFrame
56
{
57
public
:
58
static
WSFrame
CreateFrame
(
const
QByteArray& Header);
59
60
bool
m_invalid
{
false
};
61
WSOpCode
m_opCode
{
WSOpTextFrame
};
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);
77
static
WSOpCode
FrameFormatForProtocol
(
MythSocketProtocol
Protocol);
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
Generated on Sat Dec 2 2023 03:22:27 for MythTV by
1.8.17