![]() |
ImFusion C++ SDK 4.5.0
|
#include <ImFusion/Stream/Network/TCPSocketClient.h>
TCP socket client implementation providing bidirectional communication. More...
TCP socket client implementation providing bidirectional communication.
Implements a TCP socket (non-web socket) client that:
| Payload | The message type for the socket, either std::string (default) or ByteBuffer. |
Public Member Functions | |
| TCPSocketClient (const std::string &ip, int port) | |
| Constructs a TCP socket client. | |
| bool | connect (int connectionTimeoutMs=500) override |
| Attempts to establish a connection to the TCP socket server with a predefined timeout when it aborts the attempt (500 milliseconds by default). | |
| bool | isConnected () const override |
| Returns true if a handshake was successful and the connection is active, false otherwise. | |
| void | disconnect () override |
| Terminates the connection and cancels the current session. | |
| void | sendMessage (Payload message) override |
| Sends a message over the network connection. | |
| Public Member Functions inherited from ImFusion::Network::TypedConnectionBase< std::string > | |
| virtual void | sendMessage (std::string message)=0 |
| Sends a message over the network connection. | |
| Public Member Functions inherited from ImFusion::SignalReceiver | |
| SignalReceiver ()=default | |
| Default constructor. | |
| SignalReceiver (const SignalReceiver &other) | |
| Copy constructor, does not copy any existing signal connections from other. | |
| SignalReceiver & | operator= (SignalReceiver rhs) |
| Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
| virtual | ~SignalReceiver () |
| Virtual destructor disconnects from all connected signals. | |
Static Public Member Functions | |
| static ConnectionBlueprint< Payload > | blueprint () |
| Creates a blueprint for TCP 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. | |
| Protected Member Functions inherited from ImFusion::SignalReceiver | |
| void | disconnectAll () |
| Disconnects all existing connections. | |
|
explicit |
Constructs a TCP socket client.
| ip | The IP address of the TCP socket server. Must be an IPv4 address in the form "xxx.xxx.xxx.xxx" or "localhost". |
| port | The port number of the TCP socket server. |
|
overridevirtual |
Attempts to establish a connection to the TCP socket server with a predefined timeout when it aborts the attempt (500 milliseconds by default).
Implements ImFusion::Network::ClientConnectionBase< std::string >.
|
overridevirtual |
Returns true if a handshake was successful and the connection is active, false otherwise.
Implements ImFusion::Network::ClientConnectionBase< std::string >.
|
overridevirtual |
Terminates the connection and cancels the current session.
Pending messages for sending are still being sent. Incoming messages that have not yet been processed are discarded.
Implements ImFusion::Network::ClientConnectionBase< std::string >.
|
override |
Sends a message over the network connection.
Emits signalMessageSent after the message has been sent.
|
static |
Creates a blueprint for TCP socket configuration.