CppServer
1.0.0.0
C++ Server Library
|
WebSocket SSL client. More...
#include <websocket_ssl_client.h>
Public Member Functions | |
WebSocketSSLClient (std::shared_ptr< Service > service, std::shared_ptr< asio::ssl::context > context, const std::string &uri) | |
Initialize WebSocket client with a given Asio service, SSL context and server URI address. More... | |
WebSocketSSLClient (const WebSocketSSLClient &)=delete | |
WebSocketSSLClient (WebSocketSSLClient &&)=default | |
virtual | ~WebSocketSSLClient ()=default |
WebSocketSSLClient & | operator= (const WebSocketSSLClient &)=delete |
WebSocketSSLClient & | operator= (WebSocketSSLClient &&)=default |
const CppCommon::UUID & | id () const noexcept |
Get the client Id. More... | |
std::shared_ptr< Service > & | service () noexcept |
Get the Asio service. More... | |
std::shared_ptr< asio::ssl::context > & | context () noexcept |
Get the client SSL context. More... | |
const std::string & | uri () const noexcept |
Get the WebSocket URI address. More... | |
WebSocketSSLClientCore & | core () noexcept |
Get the WebSocket client core. More... | |
uint64_t | messages_sent () const noexcept |
Get the number messages sent by this client. More... | |
uint64_t | messages_received () const noexcept |
Get the number messages received by this client. More... | |
uint64_t | bytes_sent () const noexcept |
Get the number of bytes sent by this client. More... | |
uint64_t | bytes_received () const noexcept |
Get the number of bytes received by this client. More... | |
bool | IsConnected () const noexcept |
Is the client connected? More... | |
bool | Connect () |
Connect the client. More... | |
bool | Disconnect (websocketpp::close::status::value code=websocketpp::close::status::normal, const std::string &reason="") |
Disconnect the client. More... | |
bool | Reconnect () |
Reconnect the client. More... | |
size_t | Send (const void *buffer, size_t size, websocketpp::frame::opcode::value opcode=websocketpp::frame::opcode::binary) |
Send data to the server. More... | |
size_t | Send (const std::string &text, websocketpp::frame::opcode::value opcode=websocketpp::frame::opcode::text) |
Send a text string to the server. More... | |
size_t | Send (const WebSocketSSLMessage &message) |
Send a message to the server. More... | |
Protected Member Functions | |
virtual void | onConnected () |
Handle client connected notification. More... | |
virtual void | onDisconnected () |
Handle client disconnected notification. More... | |
virtual void | onReceived (const WebSocketSSLMessage &message) |
Handle message received notification. More... | |
virtual void | onError (int error, const std::string &category, const std::string &message) |
Handle error notification. More... | |
WebSocket SSL client.
WebSocket SSL client is used to read/write data from/into the connected WebSocket SSL server.
Thread-safe.
Definition at line 26 of file websocket_ssl_client.h.
|
explicit |
Initialize WebSocket client with a given Asio service, SSL context and server URI address.
service | - Asio service |
context | - SSL context |
uri | - WebSocket URI address |
Definition at line 14 of file websocket_ssl_client.cpp.
|
delete |
|
default |
|
virtualdefault |
|
inlinenoexcept |
Get the number of bytes received by this client.
Definition at line 62 of file websocket_ssl_client.h.
|
inlinenoexcept |
Get the number of bytes sent by this client.
Definition at line 60 of file websocket_ssl_client.h.
bool CppServer::Asio::WebSocketSSLClient::Connect | ( | ) |
Connect the client.
Definition at line 55 of file websocket_ssl_client.cpp.
|
noexcept |
Get the client SSL context.
|
inlinenoexcept |
Get the WebSocket client core.
Definition at line 53 of file websocket_ssl_client.h.
|
inline |
Disconnect the client.
code | - Close code to send (default is normal) |
reason | - Close reason to send (default is "") |
Definition at line 78 of file websocket_ssl_client.h.
|
inlinenoexcept |
Get the client Id.
Definition at line 44 of file websocket_ssl_client.h.
|
inlinenoexcept |
Is the client connected?
Definition at line 65 of file websocket_ssl_client.h.
|
inlinenoexcept |
Get the number messages received by this client.
Definition at line 58 of file websocket_ssl_client.h.
|
inlinenoexcept |
Get the number messages sent by this client.
Definition at line 56 of file websocket_ssl_client.h.
|
inlineprotectedvirtual |
Handle client connected notification.
Definition at line 109 of file websocket_ssl_client.h.
|
inlineprotectedvirtual |
Handle client disconnected notification.
Definition at line 111 of file websocket_ssl_client.h.
|
inlineprotectedvirtual |
Handle error notification.
error | - Error code |
category | - Error category |
message | - Error message |
Definition at line 125 of file websocket_ssl_client.h.
|
inlineprotectedvirtual |
Handle message received notification.
message | - Received message |
Definition at line 117 of file websocket_ssl_client.h.
|
delete |
|
default |
bool CppServer::Asio::WebSocketSSLClient::Reconnect | ( | ) |
Reconnect the client.
Definition at line 166 of file websocket_ssl_client.cpp.
size_t CppServer::Asio::WebSocketSSLClient::Send | ( | const void * | buffer, |
size_t | size, | ||
websocketpp::frame::opcode::value | opcode = websocketpp::frame::opcode::binary |
||
) |
Send data to the server.
buffer | - Buffer to send |
size | - Buffer size |
opcode | - Data opcode (default is websocketpp::frame::opcode::binary) |
Definition at line 177 of file websocket_ssl_client.cpp.
size_t CppServer::Asio::WebSocketSSLClient::Send | ( | const std::string & | text, |
websocketpp::frame::opcode::value | opcode = websocketpp::frame::opcode::text |
||
) |
Send a text string to the server.
text | - Text string to send |
opcode | - Data opcode (default is websocketpp::frame::opcode::text) |
Definition at line 202 of file websocket_ssl_client.cpp.
size_t CppServer::Asio::WebSocketSSLClient::Send | ( | const WebSocketSSLMessage & | message | ) |
Send a message to the server.
message | - Message to send |
Definition at line 224 of file websocket_ssl_client.cpp.
|
inlinenoexcept |
Get the Asio service.
Definition at line 47 of file websocket_ssl_client.h.
|
inlinenoexcept |
Get the WebSocket URI address.
Definition at line 51 of file websocket_ssl_client.h.