![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/Stream/Network/UDPSocket.h>
UDP socket implementation for network communication. More...
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.
| Payload | The message type for the socket, either std::string (default) or ByteBuffer. |
Public Member Functions | |
| 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. | |
| Public Member Functions inherited from ImFusion::Network::TypedConnectionBase< std::string > | |
| virtual void | sendMessage (std::string message)=0 |
| Sends a message over the network connection. | |
Static Public Member Functions | |
| static ConnectionBlueprint< Payload > | blueprint () |
| Creates a blueprint for socket configuration. | |
Additional Inherited Members | |
| Public Attributes inherited from ImFusion::Network::TypedConnectionBase< std::string > | |
| ProtectedSignal< std::shared_ptr< const std::string > > | signalNewMessage |
| Signal emitted when a new message is received. | |
| ProtectedSignal< std::shared_ptr< const std::string > > | signalMessageSent |
| Signal emitted when a message is sent. | |
|
explicit |
Constructs a UDP socket.
| 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). |
| bool ImFusion::Network::UDPSocket< Payload >::run | ( | ) |
Starts a listening thread that processes incoming messages and emits them via signalNewMessage.
| bool ImFusion::Network::UDPSocket< Payload >::stop | ( | ) |
Stops the listening thread.
| bool ImFusion::Network::UDPSocket< Payload >::isRunning | ( | ) | const |
Checks the current status of the socket.
|
override |
Sends a message to the configured peer.
| message | The message to be sent |
|
static |
Creates a blueprint for socket configuration.