SNode.C
Loading...
Searching...
No Matches
core::socket::stream::ClientFlowController Class Reference

#include <ClientFlowController.h>

Inheritance diagram for core::socket::stream::ClientFlowController:
Collaboration diagram for core::socket::stream::ClientFlowController:

Public Member Functions

 ClientFlowController (net::config::ConfigInstance *configInstance)
void stopReconnect ()
bool isReconnectEnabled () const
ClientFlowControllersetOnFlowReconnect (const std::function< void(ClientFlowController *)> &callback)
Public Member Functions inherited from core::socket::stream::FlowController< ClientFlowController >
 FlowController (net::config::ConfigInstance *configInstance)
FlowControlleroperator= (const FlowController &)=delete
virtual ~FlowController ()
std::string getInstanceName () const
uint64_t getId () const
bool terminateFlow ()
bool isTerminated () const
void stopRetry ()
bool isRetryEnabled () const
ClientFlowControllersetOnFlowRetry (const std::function< void(ClientFlowController *)> &callback)
ClientFlowControllersetOnFlowCompleted (const std::function< void(uint64_t, const std::string &)> &callback)
ClientFlowControllersetOnFlowTerminated (const std::function< void(ClientFlowController *)> &callback)
void startFlow (const std::function< void()> &callback)

Private Member Functions

void reportFlowReconnect ()
void observeConnectEventReceiver (core::eventreceiver::ConnectEventReceiver *connectEventReceiver)
void armReconnectTimer (double timeoutSeconds, const std::function< void()> &dispatcher)
void terminateAsyncSubFlow () override
void cancelReconnectTimer ()

Private Attributes

bool reconnectEnabled {true}
std::set< core::eventreceiver::ConnectEventReceiver * > connectEventReceivers
std::unique_ptr< core::timer::TimerreconnectTimer
std::function< void(ClientFlowController *)> onFlowReconnectCallback

Friends

template<typename SocketConnectorT, typename SocketContextFactoryT, typename... Args>
class SocketClient

Additional Inherited Members

Protected Member Functions inherited from core::socket::stream::FlowController< ClientFlowController >
void reportFlowRetry ()
void armRetryTimer (double timeoutSeconds, const std::function< void()> &dispatcher)

Detailed Description

Definition at line 70 of file ClientFlowController.h.

Constructor & Destructor Documentation

◆ ClientFlowController()

core::socket::stream::ClientFlowController::ClientFlowController ( net::config::ConfigInstance * configInstance)

Definition at line 19 of file ClientFlowController.cpp.

20 : FlowController(configInstance)
22 }) {
23 }
std::function< void(ClientFlowController *)> onFlowReconnectCallback
ClientFlowController(net::config::ConfigInstance *configInstance)
FlowController(net::config::ConfigInstance *configInstance)

References core::socket::stream::FlowController< ConcreteFlowController >::FlowController(), and onFlowReconnectCallback.

Here is the call graph for this function:

Member Function Documentation

◆ armReconnectTimer()

void core::socket::stream::ClientFlowController::armReconnectTimer ( double timeoutSeconds,
const std::function< void()> & dispatcher )
private

Definition at line 58 of file ClientFlowController.cpp.

58 {
59 if (reconnectEnabled) {
60 reconnectTimer = std::make_unique<core::timer::Timer>(core::timer::Timer::singleshotTimer(dispatcher, timeoutSeconds));
61 }
62 }
std::unique_ptr< core::timer::Timer > reconnectTimer
static Timer singleshotTimer(const std::function< void()> &dispatcher, const utils::Timeval &timeout)
Definition Timer.cpp:57

References reconnectEnabled, reconnectTimer, and core::timer::Timer::singleshotTimer().

Here is the call graph for this function:

◆ cancelReconnectTimer()

void core::socket::stream::ClientFlowController::cancelReconnectTimer ( )
private

Definition at line 77 of file ClientFlowController.cpp.

77 {
78 if (reconnectTimer) {
79 reconnectTimer->cancel();
80 reconnectTimer.reset();
81 }
82 }

References core::Timer::cancel(), and reconnectTimer.

Referenced by stopReconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isReconnectEnabled()

bool core::socket::stream::ClientFlowController::isReconnectEnabled ( ) const

Definition at line 30 of file ClientFlowController.cpp.

30 {
31 return reconnectEnabled;
32 }

References reconnectEnabled.

◆ observeConnectEventReceiver()

void core::socket::stream::ClientFlowController::observeConnectEventReceiver ( core::eventreceiver::ConnectEventReceiver * connectEventReceiver)
private

Definition at line 48 of file ClientFlowController.cpp.

48 {
49 if (connectEventReceiver != nullptr) {
50 if (connectEventReceiver->isEnabled()) {
51 connectEventReceivers.insert(connectEventReceiver);
52 } else {
53 connectEventReceivers.erase(connectEventReceiver);
54 }
55 }
56 }
std::set< core::eventreceiver::ConnectEventReceiver * > connectEventReceivers

References connectEventReceivers, and core::DescriptorEventReceiver::isEnabled().

Here is the call graph for this function:

◆ reportFlowReconnect()

void core::socket::stream::ClientFlowController::reportFlowReconnect ( )
private

Definition at line 44 of file ClientFlowController.cpp.

44 {
46 }

References onFlowReconnectCallback.

◆ setOnFlowReconnect()

ClientFlowController * core::socket::stream::ClientFlowController::setOnFlowReconnect ( const std::function< void(ClientFlowController *)> & callback)

Definition at line 34 of file ClientFlowController.cpp.

34 {
35 const std::function<void(ClientFlowController*)> oldCallback = onFlowReconnectCallback;
36 onFlowReconnectCallback = [oldCallback, callback](ClientFlowController* flowController) {
37 oldCallback(flowController);
38 callback(flowController);
39 };
40
41 return this;
42 }

References onFlowReconnectCallback.

◆ stopReconnect()

void core::socket::stream::ClientFlowController::stopReconnect ( )

Definition at line 25 of file ClientFlowController.cpp.

References cancelReconnectTimer(), and reconnectEnabled.

Referenced by terminateAsyncSubFlow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ terminateAsyncSubFlow()

void core::socket::stream::ClientFlowController::terminateAsyncSubFlow ( )
overrideprivatevirtual

Implements core::socket::stream::FlowController< ClientFlowController >.

Definition at line 64 of file ClientFlowController.cpp.

64 {
66 stopRetry();
67
68 for (core::eventreceiver::ConnectEventReceiver* connectEventReceiver : connectEventReceivers) {
69 if (connectEventReceiver != nullptr) {
70 connectEventReceiver->stopConnect();
71 }
72 }
73
75 }

References connectEventReceivers, core::eventreceiver::ConnectEventReceiver::stopConnect(), stopReconnect(), and core::socket::stream::FlowController< ConcreteFlowController >::stopRetry().

Here is the call graph for this function:

◆ SocketClient

template<typename SocketConnectorT, typename SocketContextFactoryT, typename... Args>
friend class SocketClient
friend

Definition at line 101 of file ClientFlowController.h.

Member Data Documentation

◆ connectEventReceivers

std::set<core::eventreceiver::ConnectEventReceiver*> core::socket::stream::ClientFlowController::connectEventReceivers
private

Definition at line 92 of file ClientFlowController.h.

Referenced by observeConnectEventReceiver(), and terminateAsyncSubFlow().

◆ onFlowReconnectCallback

std::function<void(ClientFlowController*)> core::socket::stream::ClientFlowController::onFlowReconnectCallback
private

◆ reconnectEnabled

bool core::socket::stream::ClientFlowController::reconnectEnabled {true}
private

Definition at line 90 of file ClientFlowController.h.

90{true};

Referenced by armReconnectTimer(), isReconnectEnabled(), and stopReconnect().

◆ reconnectTimer

std::unique_ptr<core::timer::Timer> core::socket::stream::ClientFlowController::reconnectTimer
private

Definition at line 94 of file ClientFlowController.h.

Referenced by armReconnectTimer(), and cancelReconnectTimer().


The documentation for this class was generated from the following files: