CppServer
1.0.4.0
C++ Server Library
|
SSL session. More...
#include <ssl_session.h>
Public Member Functions | |
SSLSession (const std::shared_ptr< SSLServer > &server) | |
Initialize the session with a given server. More... | |
SSLSession (const SSLSession &)=delete | |
SSLSession (SSLSession &&)=delete | |
virtual | ~SSLSession ()=default |
SSLSession & | operator= (const SSLSession &)=delete |
SSLSession & | operator= (SSLSession &&)=delete |
const CppCommon::UUID & | id () const noexcept |
Get the session Id. More... | |
std::shared_ptr< SSLServer > & | server () noexcept |
Get the server. More... | |
std::shared_ptr< asio::io_service > & | io_service () noexcept |
Get the Asio IO service. More... | |
asio::io_service::strand & | strand () noexcept |
Get the Asio service strand for serialized handler execution. More... | |
asio::ssl::stream< asio::ip::tcp::socket > & | stream () noexcept |
Get the session SSL stream. More... | |
asio::ssl::stream< asio::ip::tcp::socket >::next_layer_type & | socket () noexcept |
Get the session socket. More... | |
uint64_t | bytes_pending () const noexcept |
Get the number of bytes pending sent by the session. More... | |
uint64_t | bytes_sent () const noexcept |
Get the number of bytes sent by the session. More... | |
uint64_t | bytes_received () const noexcept |
Get the number of bytes received by the session. More... | |
size_t | option_receive_buffer_limit () const noexcept |
Get the option: receive buffer limit. More... | |
size_t | option_receive_buffer_size () const |
Get the option: receive buffer size. More... | |
size_t | option_send_buffer_limit () const noexcept |
Get the option: send buffer limit. More... | |
size_t | option_send_buffer_size () const |
Get the option: send buffer size. More... | |
bool | IsConnected () const noexcept |
Is the session connected? More... | |
bool | IsHandshaked () const noexcept |
Is the session handshaked? More... | |
virtual bool | Disconnect () |
Disconnect the session. More... | |
virtual size_t | Send (const void *buffer, size_t size) |
Send data to the client (synchronous) More... | |
virtual size_t | Send (std::string_view text) |
Send text to the client (synchronous) More... | |
virtual size_t | Send (const void *buffer, size_t size, const CppCommon::Timespan &timeout) |
Send data to the client with timeout (synchronous) More... | |
virtual size_t | Send (std::string_view text, const CppCommon::Timespan &timeout) |
Send text to the client with timeout (synchronous) More... | |
virtual bool | SendAsync (const void *buffer, size_t size) |
Send data to the client (asynchronous) More... | |
virtual bool | SendAsync (std::string_view text) |
Send text to the client (asynchronous) More... | |
virtual size_t | Receive (void *buffer, size_t size) |
Receive data from the client (synchronous) More... | |
virtual std::string | Receive (size_t size) |
Receive text from the client (synchronous) More... | |
virtual size_t | Receive (void *buffer, size_t size, const CppCommon::Timespan &timeout) |
Receive data from the client with timeout (synchronous) More... | |
virtual std::string | Receive (size_t size, const CppCommon::Timespan &timeout) |
Receive text from the client with timeout (synchronous) More... | |
virtual void | ReceiveAsync () |
Receive data from the client (asynchronous) More... | |
void | SetupReceiveBufferLimit (size_t limit) noexcept |
Setup option: receive buffer limit. More... | |
void | SetupReceiveBufferSize (size_t size) |
Setup option: receive buffer size. More... | |
void | SetupSendBufferLimit (size_t limit) noexcept |
Setup option: send buffer limit. More... | |
void | SetupSendBufferSize (size_t size) |
Setup option: send buffer size. More... | |
Protected Member Functions | |
virtual void | onConnected () |
Handle session connected notification. More... | |
virtual void | onHandshaked () |
Handle session handshaked notification. More... | |
virtual void | onDisconnected () |
Handle session disconnected notification. More... | |
virtual void | onReceived (const void *buffer, size_t size) |
Handle buffer received notification. More... | |
virtual void | onSent (size_t sent, size_t pending) |
Handle buffer sent notification. More... | |
virtual void | onEmpty () |
Handle empty send buffer notification. More... | |
virtual void | onError (int error, const std::string &category, const std::string &message) |
Handle error notification. More... | |
Friends | |
class | SSLServer |
SSL session.
SSL session is used to read and write data from the connected SSL client.
Thread-safe.
Definition at line 27 of file ssl_session.h.
|
explicit |
Initialize the session with a given server.
server | - Connected server |
Definition at line 15 of file ssl_session.cpp.
|
delete |
|
delete |
|
virtualdefault |
|
inlinenoexcept |
Get the number of bytes pending sent by the session.
Definition at line 59 of file ssl_session.h.
|
inlinenoexcept |
Get the number of bytes received by the session.
Definition at line 63 of file ssl_session.h.
|
inlinenoexcept |
Get the number of bytes sent by the session.
Definition at line 61 of file ssl_session.h.
|
inlinevirtual |
Disconnect the session.
Definition at line 83 of file ssl_session.h.
|
inlinenoexcept |
Get the session Id.
Definition at line 45 of file ssl_session.h.
|
inlinenoexcept |
Get the Asio IO service.
Definition at line 50 of file ssl_session.h.
|
inlinenoexcept |
Is the session connected?
Definition at line 75 of file ssl_session.h.
|
inlinenoexcept |
Is the session handshaked?
Definition at line 77 of file ssl_session.h.
|
inlineprotectedvirtual |
Handle session connected notification.
Definition at line 195 of file ssl_session.h.
|
inlineprotectedvirtual |
Handle session disconnected notification.
Reimplemented in CppServer::WS::WSSSession, and CppServer::HTTP::HTTPSSession.
Definition at line 199 of file ssl_session.h.
|
inlineprotectedvirtual |
Handle empty send buffer notification.
Notification is called when the send buffer is empty and ready for a new data to send.
This handler could be used to send another buffer to the client.
Definition at line 230 of file ssl_session.h.
|
inlineprotectedvirtual |
Handle error notification.
error | - Error code |
category | - Error category |
message | - Error message |
Definition at line 238 of file ssl_session.h.
|
inlineprotectedvirtual |
Handle session handshaked notification.
Definition at line 197 of file ssl_session.h.
|
inlineprotectedvirtual |
Handle buffer received notification.
Notification is called when another part of buffer was received from the client.
buffer | - Received buffer |
size | - Received buffer size |
Reimplemented in CppServer::WS::WSSSession, and CppServer::HTTP::HTTPSSession.
Definition at line 209 of file ssl_session.h.
|
inlineprotectedvirtual |
Handle buffer sent notification.
Notification is called when another part of buffer was sent to the client.
This handler could be used to send another buffer to the client for instance when the pending size is zero.
sent | - Size of sent buffer |
pending | - Size of pending buffer |
Definition at line 221 of file ssl_session.h.
|
delete |
|
delete |
|
inlinenoexcept |
Get the option: receive buffer limit.
Definition at line 66 of file ssl_session.h.
size_t CppServer::Asio::SSLSession::option_receive_buffer_size | ( | ) | const |
Get the option: receive buffer size.
Definition at line 34 of file ssl_session.cpp.
|
inlinenoexcept |
Get the option: send buffer limit.
Definition at line 70 of file ssl_session.h.
size_t CppServer::Asio::SSLSession::option_send_buffer_size | ( | ) | const |
Get the option: send buffer size.
Definition at line 41 of file ssl_session.cpp.
|
virtual |
Receive text from the client (synchronous)
size | - Text size to receive |
Definition at line 399 of file ssl_session.cpp.
|
virtual |
Receive text from the client with timeout (synchronous)
size | - Text size to receive |
timeout | - Timeout |
Definition at line 470 of file ssl_session.cpp.
|
virtual |
Receive data from the client (synchronous)
buffer | - Buffer to receive |
size | - Buffer size to receive |
Definition at line 363 of file ssl_session.cpp.
|
virtual |
Receive data from the client with timeout (synchronous)
buffer | - Buffer to receive |
size | - Buffer size to receive |
timeout | - Timeout |
Definition at line 406 of file ssl_session.cpp.
|
virtual |
Receive data from the client (asynchronous)
Definition at line 477 of file ssl_session.cpp.
|
virtual |
Send data to the client (synchronous)
buffer | - Buffer to send |
size | - Buffer size |
Definition at line 211 of file ssl_session.cpp.
|
virtual |
Send data to the client with timeout (synchronous)
buffer | - Buffer to send |
size | - Buffer size |
timeout | - Timeout |
Definition at line 247 of file ssl_session.cpp.
|
inlinevirtual |
Send text to the client (synchronous)
text | - Text to send |
Definition at line 97 of file ssl_session.h.
|
inlinevirtual |
Send text to the client with timeout (synchronous)
text | - Text to send |
timeout | - Timeout |
Definition at line 113 of file ssl_session.h.
|
virtual |
Send data to the client (asynchronous)
buffer | - Buffer to send |
size | - Buffer size |
Definition at line 311 of file ssl_session.cpp.
|
inlinevirtual |
Send text to the client (asynchronous)
text | - Text to send |
Definition at line 127 of file ssl_session.h.
|
inlinenoexcept |
Get the server.
Definition at line 48 of file ssl_session.h.
|
inlinenoexcept |
Setup option: receive buffer limit.
The session will be disconnected if the receive buffer limit is met. Default is unlimited.
limit | - Receive buffer limit |
Definition at line 169 of file ssl_session.h.
void CppServer::Asio::SSLSession::SetupReceiveBufferSize | ( | size_t | size | ) |
Setup option: receive buffer size.
This option will setup SO_RCVBUF if the OS support this feature.
size | - Receive buffer size |
Definition at line 48 of file ssl_session.cpp.
|
inlinenoexcept |
Setup option: send buffer limit.
The session will be disconnected if the send buffer limit is met. Default is unlimited.
limit | - Send buffer limit |
Definition at line 184 of file ssl_session.h.
void CppServer::Asio::SSLSession::SetupSendBufferSize | ( | size_t | size | ) |
Setup option: send buffer size.
This option will setup SO_SNDBUF if the OS support this feature.
size | - Send buffer size |
Definition at line 54 of file ssl_session.cpp.
|
inlinenoexcept |
Get the session socket.
Definition at line 56 of file ssl_session.h.
|
inlinenoexcept |
Get the Asio service strand for serialized handler execution.
Definition at line 52 of file ssl_session.h.
|
inlinenoexcept |
Get the session SSL stream.
Definition at line 54 of file ssl_session.h.
|
friend |
Definition at line 29 of file ssl_session.h.