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 CORE_SOCKET_STREAM_LEGACY_SOCKETCONNECTION_H
43#define CORE_SOCKET_STREAM_LEGACY_SOCKETCONNECTION_H
45#include "core/socket/stream/SocketConnection.h"
46#include "core/socket/stream/legacy/SocketReader.h"
47#include "core/socket/stream/legacy/SocketWriter.h"
49#ifndef DOXYGEN_SHOULD_SKIP_THIS
57 template <
typename PhysicalSocketT,
typename ConfigT>
58 class SocketConnection final
69 using Config = ConfigT;
70 using PhysicalSocket = PhysicalSocketT;
71 using SocketReader =
typename Super::SocketReader;
72 using SocketWriter =
typename Super::SocketWriter;
75 using SocketAddress =
typename Super::SocketAddress;
78 const std::function<
void(SocketConnection*)>& onDisconnect,
79 const std::shared_ptr<Config>& config);
81 template <
typename PhysicalSocket,
typename Config>
84 template <
typename PhysicalSocket,
typename Config>
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
SocketConnection(PhysicalSocket &&physicalSocket, const std::function< void(SocketConnection *)> &onDisconnect, const std::shared_ptr< Config > &config)
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)