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

#include <AutoConnectControl.h>

Collaboration diagram for core::socket::stream::AutoConnectControl:

Public Member Functions

 AutoConnectControl ()
 AutoConnectControl (const AutoConnectControl &)=delete
AutoConnectControloperator= (const AutoConnectControl &)=delete
 AutoConnectControl (AutoConnectControl &&)=delete
AutoConnectControloperator= (AutoConnectControl &&)=delete
 ~AutoConnectControl ()
void stopRetry ()
void stopReconnect ()
void stopReconnectAndRetry ()
bool isRetryEnabled () const
bool isReconnectEnabled () const
AutoConnectControlsetOnDestroy (const std::function< void(AutoConnectControl *)> &onDestroy)

Private Member Functions

void armRetryTimer (double timeoutSeconds, const std::function< void()> &dispatcher)
void armReconnectTimer (double timeoutSeconds, const std::function< void()> &dispatcher)
void cancelRetryTimer ()
void cancelReconnectTimer ()

Private Attributes

bool retryEnabled {true}
bool reconnectEnabled {true}
std::unique_ptr< core::timer::TimerretryTimer
std::unique_ptr< core::timer::TimerreconnectTimer
std::function< void(AutoConnectControl *)> onDestroy

Friends

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

Detailed Description

Definition at line 70 of file AutoConnectControl.h.

Constructor & Destructor Documentation

◆ AutoConnectControl() [1/3]

core::socket::stream::AutoConnectControl::AutoConnectControl ( )

Definition at line 52 of file AutoConnectControl.cpp.

References onDestroy.

◆ AutoConnectControl() [2/3]

core::socket::stream::AutoConnectControl::AutoConnectControl ( const AutoConnectControl & )
delete

◆ AutoConnectControl() [3/3]

core::socket::stream::AutoConnectControl::AutoConnectControl ( AutoConnectControl && )
delete

◆ ~AutoConnectControl()

core::socket::stream::AutoConnectControl::~AutoConnectControl ( )

Definition at line 57 of file AutoConnectControl.cpp.

57 {
58 onDestroy(this);
59 };

References onDestroy.

Member Function Documentation

◆ armReconnectTimer()

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

Definition at line 105 of file AutoConnectControl.cpp.

105 {
106 if (reconnectEnabled) {
107 reconnectTimer = std::make_unique<core::timer::Timer>(core::timer::Timer::singleshotTimer(dispatcher, timeoutSeconds));
108 }
109 }
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:

◆ armRetryTimer()

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

Definition at line 99 of file AutoConnectControl.cpp.

99 {
100 if (retryEnabled) {
101 retryTimer = std::make_unique<core::timer::Timer>(core::timer::Timer::singleshotTimer(dispatcher, timeoutSeconds));
102 }
103 }
std::unique_ptr< core::timer::Timer > retryTimer

References retryEnabled, retryTimer, and core::timer::Timer::singleshotTimer().

Here is the call graph for this function:

◆ cancelReconnectTimer()

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

Definition at line 118 of file AutoConnectControl.cpp.

118 {
119 if (reconnectTimer) {
120 reconnectTimer->cancel();
121 reconnectTimer.reset();
122 }
123 }

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

Referenced by stopReconnect(), and stopReconnectAndRetry().

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

◆ cancelRetryTimer()

void core::socket::stream::AutoConnectControl::cancelRetryTimer ( )
private

Definition at line 111 of file AutoConnectControl.cpp.

111 {
112 if (retryTimer) {
113 retryTimer->cancel();
114 retryTimer.reset();
115 }
116 }

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

Referenced by stopReconnectAndRetry(), and stopRetry().

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

◆ isReconnectEnabled()

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

Definition at line 85 of file AutoConnectControl.cpp.

85 {
86 return reconnectEnabled;
87 }

References reconnectEnabled.

◆ isRetryEnabled()

bool core::socket::stream::AutoConnectControl::isRetryEnabled ( ) const

Definition at line 81 of file AutoConnectControl.cpp.

81 {
82 return retryEnabled;
83 }

References retryEnabled.

◆ operator=() [1/2]

AutoConnectControl & core::socket::stream::AutoConnectControl::operator= ( AutoConnectControl && )
delete

◆ operator=() [2/2]

AutoConnectControl & core::socket::stream::AutoConnectControl::operator= ( const AutoConnectControl & )
delete

◆ setOnDestroy()

AutoConnectControl * core::socket::stream::AutoConnectControl::setOnDestroy ( const std::function< void(AutoConnectControl *)> & onDestroy)

Definition at line 89 of file AutoConnectControl.cpp.

89 {
90 const std::function<void(AutoConnectControl*)> oldOnDestroy = this->onDestroy;
91
92 this->onDestroy = [oldOnDestroy, onDestroy](AutoConnectControl* control) {
93 oldOnDestroy(control);
94 onDestroy(control);
95 };
96 return this;
97 }

References onDestroy.

◆ stopReconnect()

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

Definition at line 67 of file AutoConnectControl.cpp.

References cancelReconnectTimer(), and reconnectEnabled.

Here is the call graph for this function:

◆ stopReconnectAndRetry()

void core::socket::stream::AutoConnectControl::stopReconnectAndRetry ( )

Definition at line 73 of file AutoConnectControl.cpp.

References cancelReconnectTimer(), cancelRetryTimer(), reconnectEnabled, and retryEnabled.

Here is the call graph for this function:

◆ stopRetry()

void core::socket::stream::AutoConnectControl::stopRetry ( )

Definition at line 61 of file AutoConnectControl.cpp.

61 {
62 retryEnabled = false;
63
65 }

References cancelRetryTimer(), and retryEnabled.

Here is the call graph for this function:

◆ SocketClient

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

Definition at line 109 of file AutoConnectControl.h.

◆ SocketServer

template<typename SocketAcceptorT, typename SocketContextFactoryT, typename... Args>
friend class SocketServer
friend

Definition at line 114 of file AutoConnectControl.h.

Member Data Documentation

◆ onDestroy

std::function<void(AutoConnectControl*)> core::socket::stream::AutoConnectControl::onDestroy
private

Definition at line 104 of file AutoConnectControl.h.

Referenced by AutoConnectControl(), setOnDestroy(), and ~AutoConnectControl().

◆ reconnectEnabled

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

Definition at line 99 of file AutoConnectControl.h.

99{true};

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

◆ reconnectTimer

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

Definition at line 102 of file AutoConnectControl.h.

Referenced by armReconnectTimer(), and cancelReconnectTimer().

◆ retryEnabled

bool core::socket::stream::AutoConnectControl::retryEnabled {true}
private

Definition at line 98 of file AutoConnectControl.h.

98{true};

Referenced by armRetryTimer(), isRetryEnabled(), stopReconnectAndRetry(), and stopRetry().

◆ retryTimer

std::unique_ptr<core::timer::Timer> core::socket::stream::AutoConnectControl::retryTimer
private

Definition at line 101 of file AutoConnectControl.h.

Referenced by armRetryTimer(), and cancelRetryTimer().


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