WebSocket utility class.
More...
#include <ws.h>
|
| static const uint8_t | WS_FIN = 0x80 |
| | Final frame.
|
| |
| static const uint8_t | WS_TEXT = 0x01 |
| | Text frame.
|
| |
| static const uint8_t | WS_BINARY = 0x02 |
| | Binary frame.
|
| |
| static const uint8_t | WS_CLOSE = 0x08 |
| | Close frame.
|
| |
| static const uint8_t | WS_PING = 0x09 |
| | Ping frame.
|
| |
| static const uint8_t | WS_PONG = 0x0A |
| | Pong frame.
|
| |
WebSocket utility class.
Definition at line 29 of file ws.h.
◆ WebSocket() [1/3]
| CppServer::WS::WebSocket::WebSocket |
( |
| ) |
|
|
inline |
Definition at line 45 of file ws.h.
◆ WebSocket() [2/3]
| CppServer::WS::WebSocket::WebSocket |
( |
const WebSocket & |
| ) |
|
|
delete |
◆ WebSocket() [3/3]
| CppServer::WS::WebSocket::WebSocket |
( |
WebSocket && |
| ) |
|
|
delete |
◆ ~WebSocket()
| CppServer::WS::WebSocket::~WebSocket |
( |
| ) |
|
|
default |
◆ ClearWSBuffers()
| void CppServer::WS::WebSocket::ClearWSBuffers |
( |
| ) |
|
◆ InitWSNonce()
| void CppServer::WS::WebSocket::InitWSNonce |
( |
| ) |
|
◆ onWSClose()
| virtual void CppServer::WS::WebSocket::onWSClose |
( |
const void * |
buffer, |
|
|
size_t |
size, |
|
|
int |
status = 1000 |
|
) |
| |
|
inlineprotectedvirtual |
◆ onWSConnected() [1/2]
| virtual void CppServer::WS::WebSocket::onWSConnected |
( |
const HTTP::HTTPRequest & |
request | ) |
|
|
inlineprotectedvirtual |
Handle WebSocket server session connected notification.
- Parameters
-
Definition at line 129 of file ws.h.
◆ onWSConnected() [2/2]
| virtual void CppServer::WS::WebSocket::onWSConnected |
( |
const HTTP::HTTPResponse & |
response | ) |
|
|
inlineprotectedvirtual |
◆ onWSConnecting() [1/2]
Handle WebSocket server session validating notification.
Notification is called when WebSocket client is connecting to the server. You can handle the connection and validate WebSocket upgrade HTTP request.
- Parameters
-
- Returns
- 'true' if the WebSocket update request is valid, 'false' if the WebSocket update request is not valid
Definition at line 124 of file ws.h.
◆ onWSConnecting() [2/2]
◆ onWSDisconnected()
| virtual void CppServer::WS::WebSocket::onWSDisconnected |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ onWSError()
| virtual void CppServer::WS::WebSocket::onWSError |
( |
const std::string & |
message | ) |
|
|
inlineprotectedvirtual |
◆ onWSPing()
| virtual void CppServer::WS::WebSocket::onWSPing |
( |
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
inlineprotectedvirtual |
◆ onWSPong()
| virtual void CppServer::WS::WebSocket::onWSPong |
( |
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
inlineprotectedvirtual |
Handle WebSocket pong notification.
- Parameters
-
| buffer | - Received buffer |
| size | - Received buffer size |
Definition at line 159 of file ws.h.
◆ onWSReceived()
| virtual void CppServer::WS::WebSocket::onWSReceived |
( |
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
inlineprotectedvirtual |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ PerformClientUpgrade()
| bool CppServer::WS::WebSocket::PerformClientUpgrade |
( |
const HTTP::HTTPResponse & |
response, |
|
|
const CppCommon::UUID & |
id |
|
) |
| |
Perform WebSocket client upgrade.
- Parameters
-
- Returns
- 'true' if the WebSocket was successfully upgrade, 'false' if the WebSocket was not upgrade
Definition at line 26 of file ws.cpp.
◆ PerformServerUpgrade()
Perform WebSocket server upgrade.
- Parameters
-
- Returns
- 'true' if the WebSocket was successfully upgrade, 'false' if the WebSocket was not upgrade
Definition at line 103 of file ws.cpp.
◆ PrepareReceiveFrame()
| void CppServer::WS::WebSocket::PrepareReceiveFrame |
( |
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
Prepare WebSocket receive frame.
- Parameters
-
| buffer | - Received buffer |
| size | - Received buffer size |
Definition at line 273 of file ws.cpp.
◆ PrepareSendFrame()
| void CppServer::WS::WebSocket::PrepareSendFrame |
( |
uint8_t |
opcode, |
|
|
bool |
mask, |
|
|
const void * |
buffer, |
|
|
size_t |
size, |
|
|
int |
status = 0 |
|
) |
| |
◆ RequiredReceiveFrameSize()
| size_t CppServer::WS::WebSocket::RequiredReceiveFrameSize |
( |
| ) |
|
◆ SendResponse()
| virtual void CppServer::WS::WebSocket::SendResponse |
( |
const HTTP::HTTPResponse & |
response | ) |
|
|
inlineprotectedvirtual |
Send WebSocket server upgrade response.
- Parameters
-
Definition at line 202 of file ws.h.
◆ ws_nonce()
| std::string_view CppServer::WS::WebSocket::ws_nonce |
( |
| ) |
const |
|
inlinenoexcept |
◆ _ws_final_received
| bool CppServer::WS::WebSocket::_ws_final_received {false} |
|
protected |
Received final flag.
Definition at line 176 of file ws.h.
◆ _ws_frame_received
| bool CppServer::WS::WebSocket::_ws_frame_received {false} |
|
protected |
Received frame flag.
Definition at line 174 of file ws.h.
◆ _ws_handshaked
| bool CppServer::WS::WebSocket::_ws_handshaked {false} |
|
protected |
Handshaked flag.
Definition at line 169 of file ws.h.
◆ _ws_header_size
| size_t CppServer::WS::WebSocket::_ws_header_size {0} |
|
protected |
Received frame header size.
Definition at line 178 of file ws.h.
◆ _ws_nonce
| std::array<uint8_t, 16> CppServer::WS::WebSocket::_ws_nonce |
|
protected |
◆ _ws_opcode
| uint8_t CppServer::WS::WebSocket::_ws_opcode |
|
protected |
Received frame opcode.
Definition at line 172 of file ws.h.
◆ _ws_payload_size
| size_t CppServer::WS::WebSocket::_ws_payload_size {0} |
|
protected |
Received frame payload size.
Definition at line 180 of file ws.h.
◆ _ws_receive_final_buffer
| std::vector<uint8_t> CppServer::WS::WebSocket::_ws_receive_final_buffer |
|
protected |
Receive final buffer.
Definition at line 184 of file ws.h.
◆ _ws_receive_frame_buffer
| std::vector<uint8_t> CppServer::WS::WebSocket::_ws_receive_frame_buffer |
|
protected |
Receive frame buffer.
Definition at line 182 of file ws.h.
◆ _ws_receive_mask
| uint8_t CppServer::WS::WebSocket::_ws_receive_mask[4] |
|
protected |
Receive mask.
Definition at line 186 of file ws.h.
◆ _ws_send_buffer
| std::vector<uint8_t> CppServer::WS::WebSocket::_ws_send_buffer |
|
protected |
Send buffer.
Definition at line 191 of file ws.h.
◆ _ws_send_lock
| std::mutex CppServer::WS::WebSocket::_ws_send_lock |
|
protected |
Send buffer lock.
Definition at line 189 of file ws.h.
◆ _ws_send_mask
| uint8_t CppServer::WS::WebSocket::_ws_send_mask[4] |
|
protected |
Send mask.
Definition at line 193 of file ws.h.
◆ WS_BINARY
| const uint8_t CppServer::WS::WebSocket::WS_BINARY = 0x02 |
|
static |
Binary frame.
Definition at line 37 of file ws.h.
◆ WS_CLOSE
| const uint8_t CppServer::WS::WebSocket::WS_CLOSE = 0x08 |
|
static |
Close frame.
Definition at line 39 of file ws.h.
◆ WS_FIN
| const uint8_t CppServer::WS::WebSocket::WS_FIN = 0x80 |
|
static |
Final frame.
Definition at line 33 of file ws.h.
◆ WS_PING
| const uint8_t CppServer::WS::WebSocket::WS_PING = 0x09 |
|
static |
Ping frame.
Definition at line 41 of file ws.h.
◆ WS_PONG
| const uint8_t CppServer::WS::WebSocket::WS_PONG = 0x0A |
|
static |
Pong frame.
Definition at line 43 of file ws.h.
◆ WS_TEXT
| const uint8_t CppServer::WS::WebSocket::WS_TEXT = 0x01 |
|
static |
Text frame.
Definition at line 35 of file ws.h.
The documentation for this class was generated from the following files: