Client
Client
#include <icy/http/client.h>HTTP client for creating and managing outgoing connections.
Public Attributes
| Return | Name | Description |
|---|---|---|
NullSignal | Shutdown |
Shutdown
NullSignal ShutdownPublic Methods
| Return | Name | Description |
|---|---|---|
Client | ||
void | stop | Stop the Client and close all connections. |
ClientConnection::Ptr | createConnectionT inline | Creates and registers a typed client connection for the given URL. The connection type is inferred from the URL scheme (http, https, ws, wss). |
ClientConnection::Ptr | createConnection inline | Creates and registers a ClientConnection for the given URL. The socket type is chosen based on the URL scheme (http/https/ws/wss). |
void | addConnection virtual | Registers a connection with this client so it is tracked and cleaned up on stop(). |
void | removeConnection virtual | Removes a previously registered connection from the client. |
Client
Client()stop
void stop()Stop the Client and close all connections.
createConnectionT
inline
template<class ConnectionT> inline ClientConnection::Ptr createConnectionT(const URL & url, uv::Loop * loop)Creates and registers a typed client connection for the given URL. The connection type is inferred from the URL scheme (http, https, ws, wss).
Parameters
ConnectionTConcrete connection type derived from ClientConnection.
Parameters
urlTarget URL. The scheme determines the socket and adapter type.loopEvent loop to use. Defaults to the default libuv loop.
Returns
Shared pointer to the created connection.
createConnection
inline
inline ClientConnection::Ptr createConnection(const URL & url, uv::Loop * loop)Creates and registers a ClientConnection for the given URL. The socket type is chosen based on the URL scheme (http/https/ws/wss).
Parameters
urlTarget URL.loopEvent loop to use. Defaults to the default libuv loop.
Returns
Shared pointer to the created connection.
addConnection
virtual
virtual void addConnection(ClientConnection::Ptr conn)Registers a connection with this client so it is tracked and cleaned up on stop().
Parameters
connThe connection to add.
removeConnection
virtual
virtual void removeConnection(ClientConnection * conn)Removes a previously registered connection from the client.
Parameters
connRaw pointer to the connection to remove.
Exceptions
std::logic_errorif the connection is not tracked by this client.
Public Static Methods
| Return | Name | Description |
|---|---|---|
Client & | instance static | Return the default HTTP Client singleton. |
void | destroy static | Destroys the default HTTP Client singleton. |
instance
static
static Client & instance()Return the default HTTP Client singleton.
destroy
static
static void destroy()Destroys the default HTTP Client singleton.
Protected Attributes
| Return | Name | Description |
|---|---|---|
ClientConnectionPtrVec | _connections |
_connections
ClientConnectionPtrVec _connectionsProtected Methods
| Return | Name | Description |
|---|---|---|
void | onConnectionClose |
onConnectionClose
void onConnectionClose(Connection & conn)