Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTSocket Class Referenceabstract

#include <OTSocket.hpp>

Inheritance diagram for opentxs::OTSocket:
Collaboration diagram for opentxs::OTSocket:

Classes

class  Defaults
 

Public Member Functions

virtual ~OTSocket ()
 
EXPORT std::mutex * GetMutex ()
 
EXPORT bool Init (const Defaults &defaults)
 
EXPORT bool Init (const Defaults &defaults, OTSettings *pSettings)
 
EXPORT bool IsInitialized () const
 
EXPORT bool HasContext () const
 
EXPORT bool IsConnected () const
 
EXPORT bool IsListening () const
 
EXPORT const OTStringGetConnectPath () const
 
EXPORT const OTStringGetBindingPath () const
 
virtual EXPORT bool NewContext ()=0
 
virtual EXPORT bool RemakeSocket (const bool bNewContext=false)=0
 
virtual EXPORT bool Connect ()=0
 
virtual EXPORT bool Listen ()=0
 
virtual EXPORT bool Connect (const OTString &strConnectPath)=0
 
virtual EXPORT bool Listen (const OTString &strBindingPath)=0
 
virtual EXPORT bool Send (const OTASCIIArmor &ascEnvelope)=0
 
virtual EXPORT bool Send (const OTASCIIArmor &ascEnvelope, const OTString &strConnectPath)=0
 
virtual EXPORT bool Receive (OTString &strServerReply)=0
 

Protected Member Functions

 OTSocket ()
 
virtual bool HandlePollingError ()=0
 
virtual bool HandleSendingError ()=0
 
virtual bool HandleReceivingError ()=0
 

Protected Attributes

int64_t m_lLatencySendMs
 
int32_t m_nLatencySendNoTries
 
int64_t m_lLatencyReceiveMs
 
int32_t m_nLatencyReceiveNoTries
 
int64_t m_lLatencyDelayAfter
 
bool m_bIsBlocking
 
bool m_bInitialized
 
bool m_HasContext
 
bool m_bConnected
 
bool m_bListening
 
OTString m_strConnectPath
 
OTString m_strBindingPath
 
OTASCIIArmor m_ascLastMsgSent
 

Detailed Description

Definition at line 147 of file OTSocket.hpp.

Constructor & Destructor Documentation

opentxs::OTSocket::OTSocket ( )
protected

Definition at line 150 of file OTSocket.cpp.

151  : m_Mutex()
152  , m_lLatencySendMs(0)
157  , m_bIsBlocking(false)
158  , m_bInitialized(false)
159  , m_HasContext(false)
160  , m_bConnected(false)
161  , m_bListening(false)
162  , m_strConnectPath("")
163  , m_strBindingPath("")
164 {
165 }
int64_t m_lLatencyDelayAfter
Definition: OTSocket.hpp:190
OTString m_strConnectPath
Definition: OTSocket.hpp:198
int32_t m_nLatencyReceiveNoTries
Definition: OTSocket.hpp:189
int32_t m_nLatencySendNoTries
Definition: OTSocket.hpp:187
OTString m_strBindingPath
Definition: OTSocket.hpp:199
int64_t m_lLatencySendMs
Definition: OTSocket.hpp:186
int64_t m_lLatencyReceiveMs
Definition: OTSocket.hpp:188
virtual opentxs::OTSocket::~OTSocket ( )
inlinevirtual

Definition at line 208 of file OTSocket.hpp.

208 {};

Member Function Documentation

virtual EXPORT bool opentxs::OTSocket::Connect ( )
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

virtual EXPORT bool opentxs::OTSocket::Connect ( const OTString strConnectPath)
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

const OTString & opentxs::OTSocket::GetBindingPath ( ) const

Definition at line 309 of file OTSocket.cpp.

310 {
311  return m_strBindingPath;
312 }
OTString m_strBindingPath
Definition: OTSocket.hpp:199
const OTString & opentxs::OTSocket::GetConnectPath ( ) const

Definition at line 304 of file OTSocket.cpp.

305 {
306  return m_strConnectPath;
307 }
OTString m_strConnectPath
Definition: OTSocket.hpp:198
std::mutex * opentxs::OTSocket::GetMutex ( )

Definition at line 197 of file OTSocket.cpp.

198 {
199  return m_Mutex.Get();
200 }
virtual bool opentxs::OTSocket::HandlePollingError ( )
protectedpure virtual
virtual bool opentxs::OTSocket::HandleReceivingError ( )
protectedpure virtual
virtual bool opentxs::OTSocket::HandleSendingError ( )
protectedpure virtual
bool opentxs::OTSocket::HasContext ( ) const

Definition at line 289 of file OTSocket.cpp.

290 {
291  return m_HasContext;
292 }
bool opentxs::OTSocket::Init ( const Defaults defaults)

Definition at line 202 of file OTSocket.cpp.

203 {
204  if (m_bInitialized) return false;
205  if (m_HasContext) return false;
206  if (m_bConnected) return false;
207  if (m_bListening) return false;
208 
209  m_lLatencySendMs = defaults.m_lLatencySendMs;
210  m_nLatencySendNoTries = defaults.m_nLatencySendNoTries;
211  m_lLatencyReceiveMs = defaults.m_lLatencyReceiveMs;
212  m_nLatencyReceiveNoTries = defaults.m_nLatencyReceiveNoTries;
213  m_lLatencyDelayAfter = defaults.m_lLatencyDelayAfter;
214  m_bIsBlocking = defaults.m_bIsBlocking;
215 
216  m_bInitialized = true;
217  return true;
218 }
int64_t m_lLatencyDelayAfter
Definition: OTSocket.hpp:190
int32_t m_nLatencyReceiveNoTries
Definition: OTSocket.hpp:189
int32_t m_nLatencySendNoTries
Definition: OTSocket.hpp:187
int64_t m_lLatencySendMs
Definition: OTSocket.hpp:186
int64_t m_lLatencyReceiveMs
Definition: OTSocket.hpp:188
bool opentxs::OTSocket::Init ( const Defaults defaults,
OTSettings pSettings 
)

Definition at line 220 of file OTSocket.cpp.

221 {
222  if (m_bInitialized) return false;
223  if (m_HasContext) return false;
224  if (m_bConnected) return false;
225  if (m_bListening) return false;
226 
227  if (nullptr == pSettings) {
228  OT_FAIL;
229  }
230 
231  bool bIsNew;
232  {
233  if (!pSettings->CheckSet_long("latency", KEY_LATENCY_SEND_MS,
234  defaults.m_lLatencySendMs,
235  m_lLatencySendMs, bIsNew)) {
236  OT_FAIL;
237  }
238  }
239  {
240  int64_t lResult = 0;
241  if (!pSettings->CheckSet_long("latency", KEY_LATENCY_SEND_NO_TRIES,
242  defaults.m_nLatencySendNoTries, lResult,
243  bIsNew)) {
244  OT_FAIL;
245  }
246  m_nLatencySendNoTries = static_cast<int32_t>(lResult);
247  }
248  {
249  if (!pSettings->CheckSet_long("latency", KEY_LATENCY_RECEIVE_MS,
250  defaults.m_lLatencyReceiveMs,
251  m_lLatencyReceiveMs, bIsNew)) {
252  OT_FAIL;
253  }
254  }
255  {
256  int64_t lResult = 0;
257  if (!pSettings->CheckSet_long("latency", KEY_LATENCY_RECEIVE_NO_TRIES,
258  defaults.m_nLatencyReceiveNoTries,
259  lResult, bIsNew)) {
260  OT_FAIL;
261  }
262  m_nLatencyReceiveNoTries = static_cast<int32_t>(lResult);
263  }
264  {
265  if (!pSettings->CheckSet_long("latency", KEY_LATENCY_DELAY_AFTER,
266  defaults.m_lLatencyDelayAfter,
267  m_lLatencyDelayAfter, bIsNew)) {
268  OT_FAIL;
269  }
270  }
271  {
272  if (!pSettings->CheckSet_bool("latency", KEY_IS_BLOCKING,
273  defaults.m_bIsBlocking, m_bIsBlocking,
274  bIsNew)) {
275  OT_FAIL;
276  }
277  }
278 
279  m_bInitialized = true;
280 
281  return true;
282 }
int64_t m_lLatencyDelayAfter
Definition: OTSocket.hpp:190
#define KEY_IS_BLOCKING
Definition: OTSocket.cpp:144
int32_t m_nLatencyReceiveNoTries
Definition: OTSocket.hpp:189
int32_t m_nLatencySendNoTries
Definition: OTSocket.hpp:187
#define KEY_LATENCY_DELAY_AFTER
Definition: OTSocket.cpp:143
#define KEY_LATENCY_SEND_NO_TRIES
Definition: OTSocket.cpp:140
int64_t m_lLatencySendMs
Definition: OTSocket.hpp:186
int64_t m_lLatencyReceiveMs
Definition: OTSocket.hpp:188
#define KEY_LATENCY_RECEIVE_NO_TRIES
Definition: OTSocket.cpp:142
#define OT_FAIL
Definition: Assert.hpp:139
#define KEY_LATENCY_RECEIVE_MS
Definition: OTSocket.cpp:141
#define KEY_LATENCY_SEND_MS
Definition: OTSocket.cpp:139
bool opentxs::OTSocket::IsConnected ( ) const

Definition at line 294 of file OTSocket.cpp.

295 {
296  return m_bConnected;
297 }
bool opentxs::OTSocket::IsInitialized ( ) const

Definition at line 284 of file OTSocket.cpp.

285 {
286  return m_bInitialized;
287 }
bool opentxs::OTSocket::IsListening ( ) const

Definition at line 299 of file OTSocket.cpp.

300 {
301  return m_bListening;
302 }
virtual EXPORT bool opentxs::OTSocket::Listen ( )
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

virtual EXPORT bool opentxs::OTSocket::Listen ( const OTString strBindingPath)
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

virtual EXPORT bool opentxs::OTSocket::NewContext ( )
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

virtual EXPORT bool opentxs::OTSocket::Receive ( OTString strServerReply)
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

virtual EXPORT bool opentxs::OTSocket::RemakeSocket ( const bool  bNewContext = false)
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

virtual EXPORT bool opentxs::OTSocket::Send ( const OTASCIIArmor ascEnvelope)
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

virtual EXPORT bool opentxs::OTSocket::Send ( const OTASCIIArmor ascEnvelope,
const OTString strConnectPath 
)
pure virtual

Implemented in opentxs::OTSocket_ZMQ_4.

Member Data Documentation

OTASCIIArmor opentxs::OTSocket::m_ascLastMsgSent
protected

Definition at line 201 of file OTSocket.hpp.

bool opentxs::OTSocket::m_bConnected
protected

Definition at line 195 of file OTSocket.hpp.

bool opentxs::OTSocket::m_bInitialized
protected

Definition at line 193 of file OTSocket.hpp.

bool opentxs::OTSocket::m_bIsBlocking
protected

Definition at line 191 of file OTSocket.hpp.

bool opentxs::OTSocket::m_bListening
protected

Definition at line 196 of file OTSocket.hpp.

bool opentxs::OTSocket::m_HasContext
protected

Definition at line 194 of file OTSocket.hpp.

int64_t opentxs::OTSocket::m_lLatencyDelayAfter
protected

Definition at line 190 of file OTSocket.hpp.

int64_t opentxs::OTSocket::m_lLatencyReceiveMs
protected

Definition at line 188 of file OTSocket.hpp.

int64_t opentxs::OTSocket::m_lLatencySendMs
protected

Definition at line 186 of file OTSocket.hpp.

int32_t opentxs::OTSocket::m_nLatencyReceiveNoTries
protected

Definition at line 189 of file OTSocket.hpp.

int32_t opentxs::OTSocket::m_nLatencySendNoTries
protected

Definition at line 187 of file OTSocket.hpp.

OTString opentxs::OTSocket::m_strBindingPath
protected

Definition at line 199 of file OTSocket.hpp.

OTString opentxs::OTSocket::m_strConnectPath
protected

Definition at line 198 of file OTSocket.hpp.


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