Loading...
Searching...
No Matches
resdb::NetChannel Class Reference

#include <net_channel.h>

Inheritance diagram for resdb::NetChannel:
resdb::MockNetChannel resdb::TransactionConstructor resdb::KVClient resdb::ResDBTestClient resdb::contract::ContractClient resdb::utxo::UTXOClient

Public Member Functions

 NetChannel (const std::string &ip, int port)
 
 NetChannel (std::unique_ptr< Socket > socket, bool connected=false)
 
virtual ~NetChannel ()=default
 
void Close ()
 
void SetSocket (std::unique_ptr< Socket > socket)
 
void SetSignatureVerifier (SignatureVerifier *verifier)
 
void SetDestReplicaInfo (const ReplicaInfo &replica)
 
virtual int SendRequest (const google::protobuf::Message &message, Request::Type cmd, bool need_response=false)
 
virtual int SendRawMessage (const google::protobuf::Message &message)
 
virtual int SendRawMessageData (const std::string &message_str)
 
virtual int RecvRawMessageStr (std::string *message)
 
virtual int RecvRawMessage (google::protobuf::Message *message)
 
virtual int RecvRawMessageData (std::string *message_str)
 
void SetRecvTimeout (int microseconds)
 
void IsLongConnection (bool long_connect_tion)
 
void SetAsyncSend (bool is_async_send)
 

Static Public Member Functions

static std::string GetRawMessageString (const google::protobuf::Message &message, SignatureVerifier *verifier=nullptr)
 

Protected Member Functions

int SendDataInternal (const std::string &data)
 
int SendFromKeepAlive (const std::string &data)
 
int Send (const std::string &data)
 
int Recv (std::string *data)
 
int Connect ()
 

Protected Attributes

SignatureVerifier * verifier_ = nullptr
 
std::unique_ptr< Socket > socket_
 
int max_retry_time_ = 3
 
std::string ip_
 
int port_
 
bool connected_ = false
 
int read_timeouts_ = 1000000
 
bool long_connect_tion_ = false
 
bool long_connecting_ = false
 
bool is_async_send_ = false
 

Detailed Description

Definition at line 49 of file net_channel.h.

Constructor & Destructor Documentation

◆ NetChannel() [1/2]

resdb::NetChannel::NetChannel ( const std::string &  ip,
int  port 
)

Definition at line 29 of file net_channel.cpp.

◆ NetChannel() [2/2]

resdb::NetChannel::NetChannel ( std::unique_ptr< Socket >  socket,
bool  connected = false 
)

Definition at line 44 of file net_channel.cpp.

◆ ~NetChannel()

virtual resdb::NetChannel::~NetChannel ( )
virtualdefault

Member Function Documentation

◆ Close()

void resdb::NetChannel::Close ( )

Definition at line 49 of file net_channel.cpp.

◆ Connect()

int resdb::NetChannel::Connect ( )
protected

Definition at line 68 of file net_channel.cpp.

◆ GetRawMessageString()

std::string resdb::NetChannel::GetRawMessageString ( const google::protobuf::Message &  message,
SignatureVerifier *  verifier = nullptr 
)
static

Definition at line 132 of file net_channel.cpp.

◆ IsLongConnection()

void resdb::NetChannel::IsLongConnection ( bool  long_connect_tion)

Definition at line 64 of file net_channel.cpp.

◆ Recv()

int resdb::NetChannel::Recv ( std::string *  data)
protected

Definition at line 121 of file net_channel.cpp.

◆ RecvRawMessage()

int resdb::NetChannel::RecvRawMessage ( google::protobuf::Message *  message)
virtual

Definition at line 201 of file net_channel.cpp.

◆ RecvRawMessageData()

int resdb::NetChannel::RecvRawMessageData ( std::string *  message_str)
virtual

Definition at line 161 of file net_channel.cpp.

◆ RecvRawMessageStr()

int resdb::NetChannel::RecvRawMessageStr ( std::string *  message)
virtual

Definition at line 186 of file net_channel.cpp.

◆ Send()

int resdb::NetChannel::Send ( const std::string &  data)
protected

Definition at line 99 of file net_channel.cpp.

◆ SendDataInternal()

int resdb::NetChannel::SendDataInternal ( const std::string &  data)
protected

Definition at line 74 of file net_channel.cpp.

◆ SendFromKeepAlive()

int resdb::NetChannel::SendFromKeepAlive ( const std::string &  data)
protected

Definition at line 79 of file net_channel.cpp.

◆ SendRawMessage()

int resdb::NetChannel::SendRawMessage ( const google::protobuf::Message &  message)
virtual

Definition at line 165 of file net_channel.cpp.

◆ SendRawMessageData()

int resdb::NetChannel::SendRawMessageData ( const std::string &  message_str)
virtual

Definition at line 157 of file net_channel.cpp.

◆ SendRequest()

int resdb::NetChannel::SendRequest ( const google::protobuf::Message &  message,
Request::Type  cmd,
bool  need_response = false 
)
virtual

Definition at line 220 of file net_channel.cpp.

◆ SetAsyncSend()

void resdb::NetChannel::SetAsyncSend ( bool  is_async_send)

Definition at line 40 of file net_channel.cpp.

◆ SetDestReplicaInfo()

void resdb::NetChannel::SetDestReplicaInfo ( const ReplicaInfo &  replica)

Definition at line 59 of file net_channel.cpp.

◆ SetRecvTimeout()

void resdb::NetChannel::SetRecvTimeout ( int  microseconds)

Definition at line 35 of file net_channel.cpp.

◆ SetSignatureVerifier()

void resdb::NetChannel::SetSignatureVerifier ( SignatureVerifier *  verifier)

Definition at line 51 of file net_channel.cpp.

◆ SetSocket()

void resdb::NetChannel::SetSocket ( std::unique_ptr< Socket >  socket)

Definition at line 55 of file net_channel.cpp.

Member Data Documentation

◆ connected_

bool resdb::NetChannel::connected_ = false
protected

Definition at line 102 of file net_channel.h.

◆ ip_

std::string resdb::NetChannel::ip_
protected

Definition at line 100 of file net_channel.h.

◆ is_async_send_

bool resdb::NetChannel::is_async_send_ = false
protected

Definition at line 106 of file net_channel.h.

◆ long_connect_tion_

bool resdb::NetChannel::long_connect_tion_ = false
protected

Definition at line 104 of file net_channel.h.

◆ long_connecting_

bool resdb::NetChannel::long_connecting_ = false
protected

Definition at line 105 of file net_channel.h.

◆ max_retry_time_

int resdb::NetChannel::max_retry_time_ = 3
protected

Definition at line 99 of file net_channel.h.

◆ port_

int resdb::NetChannel::port_
protected

Definition at line 101 of file net_channel.h.

◆ read_timeouts_

int resdb::NetChannel::read_timeouts_ = 1000000
protected

Definition at line 103 of file net_channel.h.

◆ socket_

std::unique_ptr<Socket> resdb::NetChannel::socket_
protected

Definition at line 98 of file net_channel.h.

◆ verifier_

SignatureVerifier* resdb::NetChannel::verifier_ = nullptr
protected

Definition at line 96 of file net_channel.h.