#include <ImFusion/Stream/Network/UDPSocket.h>
UDP socket implementation for network communication.
More...
template<typename Payload = std::string>
class ImFusion::Network::UDPSocket< Payload >
UDP socket implementation for network communication.
Provides a UDP socket that can send and receive messages of type Payload. It manages its own network thread for asynchronous operations.
- Template Parameters
-
- Note
- Messages are sent and received asynchronously.
|
| | UDPSocket (const std::string &peerIp, unsigned short peerPort, const std::string &ownIp="0.0.0.0", unsigned short ownPort=0) |
| | Constructs a UDP socket.
|
| |
|
| ~UDPSocket () override |
| | Cleans up network resources.
|
| |
| bool | run () |
| | Starts a listening thread that processes incoming messages and emits them via signalNewMessage.
|
| |
| bool | stop () |
| | Stops the listening thread.
|
| |
| bool | isRunning () const |
| | Checks the current status of the socket.
|
| |
| void | sendMessage (Payload message) override |
| | Sends a message to the configured peer.
|
| |
| virtual void | sendMessage (std::string message)=0 |
| | Sends a message over the network connection.
|
| |
◆ UDPSocket()
template<typename Payload = std::string>
Constructs a UDP socket.
- Parameters
-
| peerIp | IP address of the remote peer. |
| peerPort | Port number of the remote peer. |
| ownIp | Local IP address to bind to (default: "0.0.0.0"). |
| ownPort | Local port to bind to (default: 0 for automatic assignment). |
- Note
- If
ownPort is 0, the system automatically assigns an available port.
◆ run()
template<typename Payload = std::string>
Starts a listening thread that processes incoming messages and emits them via signalNewMessage.
- Returns
- true if successfully started, false otherwise.
◆ stop()
template<typename Payload = std::string>
Stops the listening thread.
- Returns
- true if successfully stopped, false otherwise.
◆ isRunning()
template<typename Payload = std::string>
Checks the current status of the socket.
- Returns
- true if the socket is running and listening for messages, false otherwise.
◆ sendMessage()
template<typename Payload = std::string>
| void sendMessage |
( |
Payload | message | ) |
|
|
override |
Sends a message to the configured peer.
- Parameters
-
| message | The message to be sent |
- Note
- The message is sent asynchronously to the peer specified in the constructor.
◆ blueprint()
template<typename Payload = std::string>
Creates a blueprint for socket configuration.
- Returns
- A blueprint defining
- Required connection parameters
- Default property values
- Socket construction logic
- Note
- The blueprint is registered with ConnectionFactory by default to facilitate UDP socket creation and configuration.
The documentation for this class was generated from the following file:
- ImFusion/Stream/Network/UDPSocket.h