Core Library 1.7.0.0 Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.

SimpleUdpReceiver.h
Go to the documentation of this file.
1 // This file is part of CoreLibrary containing useful reusable utility
2 // classes.
3 //
4 // Copyright (C) 2014 to present, Duncan Crutchley
5 // Contact <dac1976github@outlook.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published
9 // by the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License and GNU Lesser General Public License
16 // for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // and GNU Lesser General Public License along with this program. If
20 // not, see <http://www.gnu.org/licenses/>.
21
27 #ifndef SIMPLEUDPRECEIVER
28 #define SIMPLEUDPRECEIVER
29
30 #include "UdpReceiver.h"
31 #include "MessageUtils.h"
32
34 namespace core_lib
35 {
37 namespace asio
38 {
40 namespace udp
41 {
42
45 class CORE_LIBRARY_DLL_SHARED_API SimpleUdpReceiver final
46 {
47 public:
49 SimpleUdpReceiver() = delete;
71 SimpleUdpReceiver(boost_iocontext_t& ioContext, uint16_t listenPort,
72 const defs::default_message_dispatcher_t& messageDispatcher,
73 eUdpOption receiveOptions = eUdpOption::broadcast,
74 size_t receiveBufferSize = DEFAULT_UDP_BUF_SIZE,
75 size_t memPoolMsgCount = 0);
96 SimpleUdpReceiver(uint16_t listenPort,
97 const defs::default_message_dispatcher_t& messageDispatcher,
98 eUdpOption receiveOptions = eUdpOption::broadcast,
99 size_t receiveBufferSize = DEFAULT_UDP_BUF_SIZE,
100 size_t memPoolMsgCount = 0);
102 SimpleUdpReceiver(const SimpleUdpReceiver&) = delete;
104 SimpleUdpReceiver& operator=(const SimpleUdpReceiver&) = delete;
106 SimpleUdpReceiver(SimpleUdpReceiver&&) = delete;
108 SimpleUdpReceiver& operator=(SimpleUdpReceiver&&) = delete;
110 ~SimpleUdpReceiver() = default;
115 uint16_t ListenPort() const;
116
117 private:
119 messages::MessageHandler m_messageHandler{};
121 UdpReceiver m_udpReceiver;
122 };
123
124 } // namespace udp
125 } // namespace asio
126 } // namespace core_lib
127
128 #endif // SIMPLEUDPRECEIVER
core_lib::asio::udp::UdpReceiver
A general purpose UDP receiver.
Definition: UdpReceiver.h:49
core_lib::asio::defs::default_message_dispatcher_t
std::function< void(default_received_message_ptr_t)> default_message_dispatcher_t
Typedef to default message dispatcher function object.
Definition: AsioDefines.h:286
core_lib::asio::udp::eUdpOption
eUdpOption
The udp options enumeration.
Definition: AsioDefines.h:98
core_lib::asio::messages::MessageHandler
Default message handler class.
Definition: MessageUtils.h:55
UdpReceiver.h
File containing UDP receiver class declaration.
core_lib
The core_lib namespace.
Definition: AsioDefines.h:59
core_lib::asio::udp::SimpleUdpReceiver
A simplified UDP receiver, which uses the class MessageHeader as the message header type...
Definition: SimpleUdpReceiver.h:45
boost_iocontext_t
boost_asio::io_context boost_iocontext_t
Boost IO context convenience typedef.
Definition: AsioDefines.h:46
MessageUtils.h
File containing message utils declaration.
core_lib::asio::udp::eUdpOption::broadcast
udp broadcasts.
core_lib::asio::udp::SimpleUdpReceiver::m_udpReceiver
UdpReceiver m_udpReceiver
Our actual typed UDP receiver object.
Definition: SimpleUdpReceiver.h:121