|
Core Library
1.7.0.0
Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.
|
A generic UDP sender. More...
#include <UdpTypedSender.h>
Public Member Functions | |
| UdpTypedSender ()=delete | |
| Default constructor - deleted. | |
| UdpTypedSender (boost_iocontext_t &ioContext, const defs::connection_t &receiver, const MsgBldr &messageBuilder, eUdpOption sendOption=eUdpOption::broadcast, size_t sendBufferSize=DEFAULT_UDP_BUF_SIZE) | |
| Initialisation constructor. More... | |
| UdpTypedSender (const defs::connection_t &receiver, const MsgBldr &messageBuilder, eUdpOption sendOption=eUdpOption::broadcast, size_t sendBufferSize=DEFAULT_UDP_BUF_SIZE) | |
| Initialisation constructor. More... | |
| UdpTypedSender (const UdpTypedSender &)=delete | |
| Copy constructor - deleted. | |
| UdpTypedSender & | operator= (const UdpTypedSender &)=delete |
| Copy assignment operator - deleted. | |
| UdpTypedSender (UdpTypedSender &&)=delete | |
| Move constructor - deleted. | |
| UdpTypedSender & | operator= (UdpTypedSender &&)=delete |
| Move assignment operator - deleted. | |
| ~UdpTypedSender ()=default | |
| Default destructor. | |
| defs::connection_t | ReceiverConnection () const |
| Retrieve receiver connection details. More... | |
| bool | SendMessage (int32_t messageId, const defs::connection_t &responseAddress=defs::NULL_CONNECTION) |
| Send a header-only message to the receiver. More... | |
| bool | SendMessage (const defs::char_buffer_t &message, int32_t messageId, const defs::connection_t &responseAddress=defs::NULL_CONNECTION) |
| Send a header plus message buffer to the receiver. More... | |
| template<typename T , class A = serialize::archives::out_port_bin_t> | |
| bool | SendMessage (const T &message, int32_t messageId, const defs::connection_t &responseAddress=defs::NULL_CONNECTION) |
| Send a full message to the server. More... | |
| bool | SendMessage (const defs::char_buffer_t &message) |
| Send a message buffer to the receiver. More... | |
Private Attributes | |
| std::mutex | m_sendMutex |
| Send message mutex. | |
| const MsgBldr & | m_messageBuilder |
| Const reference to message builder object. | |
| UdpSender | m_udpSender |
| Underlying UDP sender object. | |
A generic UDP sender.
The template argument defines a message builder object that must have an interface compatible with that of the class core_lib::asio::messages::MessageBuilder.
This class forms the underpinnings of the SimpleUdpSender class.
This is also the class to be used when the user wants to specify their own message builder type and message header type.
|
inline |
Initialisation constructor.
| [in] | ioContext | - External boost IO context to manage ASIO. |
| [in] | receiver | - Connection object describing target receiver's address and port. |
| [in] | messageBuilder | - Message builder object reference. |
| [in] | sendOption | - Socket send option to control the use of broadcasts/unicast. |
| [in] | sendBufferSize | - Socket send option to control send buffer size. |
Typically use this constructor when managing a bool of threads using an instance of core_lib::asio::IoContextThreadGroup in your application to manage a pool of std::threads. This means you can use a single thread pool and all ASIO operations will be exectued using this thread pool managed by a single IO context. This is the recommended constructor.
|
inline |
Initialisation constructor.
| [in] | receiver | - Connection object describing target receiver's address and port. |
| [in] | messageBuilder | - Message builder object reference. |
| [in] | sendOption | - Socket send option to control the use of broadcasts/unicast. |
| [in] | sendBufferSize | - Socket send option to control send buffer size. |
This constructor does not require an external IO context to run instead it creates its own IO context object along with its own thread. For very simple cases this version will be fine but in more performance and resource critical situations the external IO context constructor is recommened.
|
inline |
Retrieve receiver connection details.
|
inline |
Send a header-only message to the receiver.
| [in] | messageId | - Unique message ID to insert into message header. |
| [in] | responseAddress | - (Optional) The address and port where the receiver should send the response, the default value will mean the response address will point to this client socket. |
|
inline |
Send a header plus message buffer to the receiver.
| [in] | message | - The message buffer. |
| [in] | messageId | - Unique message ID to insert into message header. |
| [in] | responseAddress | - (Optional) The address and port where the receiver should send the response, the default value will mean the response address will point to this client socket. |
|
inline |
Send a full message to the server.
| [in] | message | - The message of type T to send behind the header serialized to an boost::serialization-compatible archive of type A. |
| [in] | messageId | - Unique message ID to insert into message header. |
| [in] | responseAddress | - (Optional) The address and port where the receiver should send the response, the default value will mean the response address will point to this client socket. |
|
inline |
Send a message buffer to the receiver.
| [in] | message | - The message buffer. |