SRS-control 0.1.4
Loading...
Searching...
No Matches
DataSocket.cpp
Go to the documentation of this file.
1#include "DataSocket.hpp"
7#include <boost/asio/awaitable.hpp>
8#include <boost/asio/detached.hpp>
9#include <boost/asio/impl/co_spawn.hpp>
10#include <cstddef>
11#include <memory>
12#include <span>
13#include <utility>
14
15namespace srs::connection
16{
18 : SpecialSocket(port_number, io_context)
19 , io_context_{ &io_context }
21 {
23 }
24
25 void DataSocket::set_buffer_size(std::size_t buffer_size) { read_msg_buffer_.resize(buffer_size); }
26
27 // WARN: is it really needed?
28 void DataSocket::register_send_action_imp(asio::awaitable<void> action,
29 const std::shared_ptr<ConnectionType>& /*connection*/)
30 {
31 asio::co_spawn(*io_context_, std::move(action), asio::detached);
32 }
33
34 void DataSocket::response_handler(const UDPEndpoint& /*endpoint*/, std::span<char> response)
35 {
36 workflow_handler_->read_data_once(response);
37 }
38
40 {
41 auto& timer = get_cancel_timer();
42 timer.cancel();
43 }
44} // namespace srs::connection
gsl::not_null< workflow::Handler * > workflow_handler_
DataSocket(int port_number, io_context_type &io_context, workflow::Handler *workflow)
gsl::not_null< io_context_type * > io_context_
void set_buffer_size(std::size_t buffer_size)
void register_send_action_imp(asio::awaitable< void > action, const std::shared_ptr< ConnectionType > &connection)
void response_handler(const UDPEndpoint &endpoint, std::span< char > response)
std::vector< char > read_msg_buffer_
constexpr auto LARGE_READ_MSG_BUFFER_SIZE
size of the data array for reading a UDP package
boost::asio::ip::basic_endpoint< boost::asio::ip::udp > UDPEndpoint
asio::thread_pool io_context_type