Older/Server/UdpServer.h
amass 08340ad5c8
All checks were successful
Deploy / PullDocker (push) Successful in 11s
Deploy / Build (push) Successful in 1m54s
add codec.
2024-09-30 16:12:57 +00:00

37 lines
972 B
C++

#ifndef UDPSERVER_H
#define UDPSERVER_H
#include <boost/asio.hpp>
class UdpServer {
public:
UdpServer(boost::asio::io_context &io_context);
protected:
/**
* @brief reveiveHandler
* @param error Result of operation.
* @param bytes_transferred Number of bytes received.
*/
void reveiveHandler(const boost::system::error_code &error, std::size_t bytes_transferred);
/**
* @brief sendHandler
* @param error Result of operation.
* @param bytes_transferred Number of bytes sent.
*/
void sendHandler(const boost::system::error_code &error, std::size_t bytes_transferred);
void handleReceivedBuffer(std::vector<char> &data);
void sendData();
private:
boost::asio::ip::udp::socket m_socket;
boost::asio::ip::udp::endpoint m_remotePoint; //客户端端点
std::vector<char> m_reveiveBuffer;
boost::asio::steady_timer m_timer;
};
#endif // UDPSERVER_H