2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#ifndef NET_IN_STREAM_LEGACY_SOCKETCLIENT_H
43#define NET_IN_STREAM_LEGACY_SOCKETCLIENT_H
47#include "core/socket/stream/legacy/SocketConnection.h"
48#include "core/socket/stream/legacy/SocketConnector.h"
49#include "net/in/stream/SocketClient.h"
50#include "net/in/stream/legacy/config/ConfigSocketClient.h"
56#ifndef DOXYGEN_SHOULD_SKIP_THIS
67 template <
typename SocketContextFactoryT,
typename... Args>
70 SocketContextFactoryT,
73 template <
typename SocketContextFactory,
typename... SocketContextFactoryArgs>
74 SocketClient<SocketContextFactory, SocketContextFactoryArgs...>
75 Client(
const std::string& instanceName,
76 const std::function<
void(
typename SocketClient<SocketContextFactory, SocketContextFactoryArgs...>::Config&)>& configurator,
77 SocketContextFactoryArgs&&... socketContextFactoryArgs) {
78 return core::socket::
stream::Client<SocketClient<SocketContextFactory, SocketContextFactoryArgs...>>(
79 instanceName, configurator, std::forward<SocketContextFactoryArgs>(socketContextFactoryArgs)...);
82 template <
typename SocketContextFactory,
83 typename... SocketContextFactoryArgs,
84 typename = std::enable_if_t<
not std::is_invocable_v<std::tuple_element_t<0, std::tuple<SocketContextFactoryArgs...>>,
85 typename SocketClient<SocketContextFactory>::Config&>>>
86 SocketClient<SocketContextFactory, SocketContextFactoryArgs...>
Client(
const std::string& instanceName,
87 SocketContextFactoryArgs&&... socketContextFactoryArgs) {
88 return core::socket::
stream::Client<SocketClient<SocketContextFactory, SocketContextFactoryArgs...>>(
89 instanceName, std::forward<SocketContextFactoryArgs>(socketContextFactoryArgs)...);
core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection) override
~SimpleSocketProtocolFactory() override
void onDisconnected() override
~SimpleSocketProtocol() override
web::http::client::ResponseParser * responseParser
SimpleSocketProtocol(core::socket::stream::SocketConnection *socketConnection)
bool onSignal(int signum) override
void onConnected() override
void onReadError(int errnum) override
void onWriteError(int errnum) override
std::size_t onReceivedFromPeer() override
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
Config & getConfig() const
static constexpr int DISABLED
static constexpr int ERROR
static constexpr int FATAL
void connect(const SocketAddress &remoteAddress, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const SocketAddress & getRemoteAddress() const final
const SocketAddress & getLocalAddress() const final
void sendToPeer(const std::string &data)
SocketContext(core::socket::stream::SocketConnection *socketConnection)
void onReadError(int errnum) override
void shutdownWrite(bool forceClose=false)
void onWriteError(int errnum) override
const std::string & getInstanceName() const
SocketAddress(const std::string &ipOrHostname, uint16_t port)
std::string getCanonName() const
std::string toString(bool expanded=true) const override
void init(const Hints &hints={.aiFlags=0,.aiSockType=0,.aiProtocol=0})
ResponseParser(core::socket::stream::SocketContext *socketContext, const std::function< void()> &onResponseStart, const std::function< void(Response &&)> &onResponseParsed, const std::function< void(int, const std::string &)> &onResponseParseError)
int main(int argc, char *argv[])
static web::http::client::ResponseParser * getResponseParser(core::socket::stream::SocketContext *socketContext)
SocketClient getLegacyClient()
SocketClient< SocketContextFactory, SocketContextFactoryArgs... > Client(const std::string &instanceName, SocketContextFactoryArgs &&... socketContextFactoryArgs)
SocketClient< SocketContextFactory, SocketContextFactoryArgs... > Client(const std::string &instanceName, const std::function< void(typename SocketClient< SocketContextFactory, SocketContextFactoryArgs... >::Config &)> &configurator, SocketContextFactoryArgs &&... socketContextFactoryArgs)