![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/Stream/Network/WebsocketClient.h>
WebSocket client implementation providing bidirectional communication. More...
WebSocket client implementation providing bidirectional communication.
Implements a WebSocket client that:
| Payload | The message type for the socket, either std::string (default) or ByteBuffer. |
Public Member Functions | |
| WebsocketClient (const std::string &ip, int port) | |
| Constructs a WebSocket 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. | |
Static Public Member Functions | |
| static ConnectionBlueprint< Payload > | blueprint () |
| Creates a blueprint for WebSocket 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 WebSocket client.
| ip | The IP address of the WebSocket server. Must be an IPv4 address in the form "xxx.xxx.xxx.xxx" or "localhost". |
| port | The port number of the WebSocket 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 WebSocket configuration.