Base socket class for sending and listening messages.
More...
#include <SpecialSocketBase.hpp>
|
| void | register_send_action (this auto &&self, asio::awaitable< void > action, const std::shared_ptr< typename std::remove_cvref_t< decltype(self)>::ConnectionType > &connection) |
| | Registering the send action.
|
| void | listen (this auto &self, io_context_type &io_context) |
| | Listen to any UDP data.
|
| auto | cancel_listen_after (this auto &&self, io_context_type &io_context, std::chrono::seconds waiting_time=std::chrono::seconds(2)) -> std::future< void > |
| | Cancelling the listening action after a certain time.
|
| auto | wait_for_listen_finish (std::chrono::seconds time) -> std::optional< std::future_status > |
| | Blocking the current thread by waiting the listen action to finish until a certain time duration.
|
| void | set_report (AppReport *report) |
| void | before_socket_close () |
| auto | get_socket () const -> udp::socket & |
| | Getter for the asio udp socket object.
|
| auto | get_port () const -> int |
| | Getter for the port number.
|
| auto | get_future () -> auto & |
| | Getter for the status of the listen action.
|
| auto | get_n_records () const -> std::size_t |
| | Getter for the number of frames read.
|
| auto | get_n_bytes () const -> std::size_t |
| | Getter for the number of bytes read.
|
| auto | get_total_time_ns () const -> std::uint64_t |
| | Getter for the total listening time in nano seconds.
|
| auto | get_report () -> auto * |
|
| template<SpecialSocketDerived SocketType, typename... Args> |
| static auto | create (int port_number, io_context_type &io_context, Args &&... args) -> std::expected< std::shared_ptr< SocketType >, std::error_code > |
|
| template<SpecialSocketDerived SocketType> |
| static auto | async_listen_all_connections (std::shared_ptr< SocketType > socket) -> asio::awaitable< void > |
Base socket class for sending and listening messages.
Definition at line 58 of file SpecialSocketBase.hpp.
◆ SpecialSocket()
| srs::connection::SpecialSocket::SpecialSocket |
( |
int | port_number, |
|
|
io_context_type & | io_context ) |
|
explicitprotected |
Projected constructor, which can only be called from the derived classes.
- Parameters
-
| port_numer | Port number binding to the socket for the listening action. |
| io_context | asio io context. |
Definition at line 18 of file SpecialSocketBase.cpp.
◆ async_listen_all_connections()
template<SpecialSocketDerived SocketType>
| auto srs::connection::SpecialSocket::async_listen_all_connections |
( |
std::shared_ptr< SocketType > | socket | ) |
-> asio::awaitable< void > |
|
staticprivate |
◆ before_socket_close()
| void srs::connection::SpecialSocket::before_socket_close |
( |
| ) |
|
|
inline |
◆ bind_socket()
| auto srs::connection::SpecialSocket::bind_socket |
( |
| ) |
-> std::error_code |
|
private |
◆ cancel_coroutine()
| auto srs::connection::SpecialSocket::cancel_coroutine |
( |
| ) |
-> asio::awaitable< void > |
|
private |
◆ cancel_listen_after()
| auto srs::connection::SpecialSocket::cancel_listen_after |
( |
this auto && | self, |
|
|
io_context_type & | io_context, |
|
|
std::chrono::seconds | waiting_time = std::chrono::seconds(2) ) -> std::future< void > |
Cancelling the listening action after a certain time.
- Parameters
-
| self | Deduce this self reference |
| io_context | Reference to the io_context |
| waiting_time | Time until the listen action is cancelled. |
- Returns
- a future object to check whether the listen action is cancelled.
Definition at line 273 of file SpecialSocketBase.hpp.
◆ close_socket()
| auto srs::connection::SpecialSocket::close_socket |
( |
| ) |
-> std::error_code |
|
private |
◆ create()
template<SpecialSocketDerived SocketType, typename... Args>
| auto srs::connection::SpecialSocket::create |
( |
int | port_number, |
|
|
io_context_type & | io_context, |
|
|
Args &&... | args ) -> std::expected< std::shared_ptr< SocketType >, std::error_code > |
|
static |
◆ get_cancel_timer()
| auto srs::connection::SpecialSocket::get_cancel_timer |
( |
| ) |
-> auto & |
|
inlineprotected |
◆ get_future()
| auto srs::connection::SpecialSocket::get_future |
( |
| ) |
-> auto & |
|
inline |
Getter for the status of the listen action.
- Returns
- The future status of the listen action coroutine.
Definition at line 131 of file SpecialSocketBase.hpp.
◆ get_n_bytes()
| auto srs::connection::SpecialSocket::get_n_bytes |
( |
| ) |
const -> std::size_t |
|
inline |
◆ get_n_records()
| auto srs::connection::SpecialSocket::get_n_records |
( |
| ) |
const -> std::size_t |
|
inline |
Getter for the number of frames read.
- Returns
- Number of frames read.
Definition at line 138 of file SpecialSocketBase.hpp.
◆ get_port()
| auto srs::connection::SpecialSocket::get_port |
( |
| ) |
const -> int |
|
inlinenodiscard |
◆ get_report()
| auto srs::connection::SpecialSocket::get_report |
( |
| ) |
-> auto * |
|
inline |
◆ get_socket()
| auto srs::connection::SpecialSocket::get_socket |
( |
| ) |
const -> udp::socket & |
|
inlinenodiscard |
Getter for the asio udp socket object.
- Returns
- shared pointer to the udp socket.
Definition at line 117 of file SpecialSocketBase.hpp.
◆ get_total_time_ns()
| auto srs::connection::SpecialSocket::get_total_time_ns |
( |
| ) |
const -> std::uint64_t |
|
inline |
Getter for the total listening time in nano seconds.
- Returns
- Total listening time.
Definition at line 152 of file SpecialSocketBase.hpp.
◆ listen()
| void srs::connection::SpecialSocket::listen |
( |
this auto & | self, |
|
|
io_context_type & | io_context ) |
Listen to any UDP data.
- Parameters
-
| self | Deduce this self reference |
| io_context | Reference to the io_context |
Definition at line 263 of file SpecialSocketBase.hpp.
◆ register_send_action()
| void srs::connection::SpecialSocket::register_send_action |
( |
this auto && | self, |
|
|
asio::awaitable< void > | action, |
|
|
const std::shared_ptr< typename std::remove_cvref_t< decltype(self)>::ConnectionType > & | connection ) |
Registering the send action.
Invoke an action corresponding the type of connection specified in the socket class. The connection type should all derive from srs::connection::ConnectionBase class.
- Parameters
-
| self | Deduce this self reference |
| action | An asio::awaitable action object. |
| connection | A connection shared pointer. |
Definition at line 249 of file SpecialSocketBase.hpp.
◆ set_report()
| void srs::connection::SpecialSocket::set_report |
( |
AppReport * | report | ) |
|
|
inline |
◆ wait_for_listen_finish()
| auto srs::connection::SpecialSocket::wait_for_listen_finish |
( |
std::chrono::seconds | time | ) |
-> std::optional< std::future_status > |
Blocking the current thread by waiting the listen action to finish until a certain time duration.
- Parameters
-
| time | Time to wait for the listen action to finish. |
- Returns
- The result of waiting.
Definition at line 51 of file SpecialSocketBase.cpp.
◆ cancel_timer_
| asio::system_timer srs::connection::SpecialSocket::cancel_timer_ |
|
private |
◆ clock_
| std::chrono::steady_clock srs::connection::SpecialSocket::clock_ |
|
private |
◆ listen_future_
| std::shared_future<std::variant<std::monostate, std::monostate> > srs::connection::SpecialSocket::listen_future_ |
|
private |
◆ n_bytes
| std::size_t srs::connection::SpecialSocket::n_bytes = 0 |
|
private |
◆ n_records_
| std::size_t srs::connection::SpecialSocket::n_records_ = 0 |
|
private |
◆ port_number_
| int srs::connection::SpecialSocket::port_number_ = 0 |
|
private |
◆ report_
| AppReport* srs::connection::SpecialSocket::report_ = nullptr |
|
private |
◆ socket_
| std::unique_ptr<udp::socket> srs::connection::SpecialSocket::socket_ |
|
private |
◆ time_point_
| std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> srs::connection::SpecialSocket::time_point_ |
|
private |
◆ total_time_ns_
| std::uint64_t srs::connection::SpecialSocket::total_time_ns_ = 0 |
|
private |
The documentation for this class was generated from the following files: