MASA-Core
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
Peer Class Reference

Detailed Description

Definition at line 57 of file Peer.hpp.

#include <Peer.hpp>

List of all members.

Public Member Functions

 Peer (int socket, const string &localId, bool initiator, int connectionType=CONNECTION_TYPE_UNKNOWN)
 Peer (string remoteId, string remoteAddress, const int remoteType, const int ringType, const int connectionType)
virtual ~Peer ()
CommandrecvCommand ()
CommandsendCommand (Command *command)
void addHook (int id, int serial=-1)
CommandwaitHook ()
bool isConnected ()
bool handshake ()
bool waitHandshake ()
void finalize ()
void send_int32 (int value)
int recv_int32 ()
void send_int16 (short value)
short recv_int16 ()
void send_int8 (char value)
char recv_int8 ()
void send_array (const char *value, int len)
void recv_array (char *value, int len)
void send_vls8 (const char *value)
void recv_vls8 (char *value, int max=-1)
void send_vls8 (const string &value)
string recv_vls8 ()
void recv_dummy (int len)
void setLocalType (int localType)
void setLocalAddress (const string &publicAddress)
const string & getLocalAddress () const
const string & getRemoteAddress () const
const string & getLocalId () const
const string & getRemoteId () const
int getLocalType () const
int getRemoteType () const
string toString ()
void setCallback (MasaNetCallbacks *callback)
bool isInitiator () const
int getSocket () const
int getConnectionType () const

Static Public Member Functions

static void registerCommandCreator (int id, cmd_creator_f creator)

Public Attributes

int ringType

Private Member Functions

bool handshakeInitiator ()
bool handshakeInitiated ()
int getNextSerial ()
void notifyHook (Command *cmd)
void handleSendError (int ret)
void handleRecvError (int ret)

Static Private Member Functions

static float getGlobalTime ()
static float getElapsedTime (timeval *end_time, timeval *start_time)

Private Attributes

MasaNetCallbackscallback
pthread_mutex_t mutex
pthread_cond_t responseCond
pthread_cond_t handshakeCond
int socket
bool initiator
bool handshakeDone
bool connected
bool error
int serial
float timeout
int connectionType
map< int, set< pthread_t > > hookThreads
map< pthread_t, Command * > hookCommand
map< pthread_t, int > hookSerial
string localId
string remoteId
string localAddress
string remoteAddress
int remoteType
int localType

Static Private Attributes

static map< int, cmd_creator_fcmdCreators
static bool hasStaticEvent = false
static timeval staticEvent

Constructor & Destructor Documentation

Peer::Peer ( int  socket,
const string &  localId,
bool  initiator,
int  connectionType = CONNECTION_TYPE_UNKNOWN 
)

Definition at line 54 of file Peer.cpp.

Peer::Peer ( string  remoteId,
string  remoteAddress,
const int  remoteType,
const int  ringType,
const int  connectionType 
)

Definition at line 96 of file Peer.cpp.

Peer::~Peer ( ) [virtual]

Definition at line 114 of file Peer.cpp.


Member Function Documentation

void Peer::addHook ( int  id,
int  serial = -1 
)

Definition at line 271 of file Peer.cpp.

void Peer::finalize ( )

Definition at line 146 of file Peer.cpp.

int Peer::getConnectionType ( ) const

Definition at line 582 of file Peer.cpp.

float Peer::getElapsedTime ( timeval *  end_time,
timeval *  start_time 
) [static, private]

Definition at line 586 of file Peer.cpp.

float Peer::getGlobalTime ( ) [static, private]

Definition at line 557 of file Peer.cpp.

const string & Peer::getLocalAddress ( ) const

Definition at line 336 of file Peer.cpp.

const string & Peer::getLocalId ( ) const

Definition at line 344 of file Peer.cpp.

int Peer::getLocalType ( ) const

Definition at line 324 of file Peer.cpp.

int Peer::getNextSerial ( ) [private]

Definition at line 319 of file Peer.cpp.

const string & Peer::getRemoteAddress ( ) const

Definition at line 340 of file Peer.cpp.

const string & Peer::getRemoteId ( ) const

Definition at line 348 of file Peer.cpp.

int Peer::getRemoteType ( ) const

Definition at line 332 of file Peer.cpp.

int Peer::getSocket ( ) const

Definition at line 578 of file Peer.cpp.

void Peer::handleRecvError ( int  ret) [private]

Definition at line 455 of file Peer.cpp.

void Peer::handleSendError ( int  ret) [private]

Definition at line 448 of file Peer.cpp.

bool Peer::handshake ( )

Definition at line 121 of file Peer.cpp.

bool Peer::handshakeInitiated ( ) [private]

Definition at line 238 of file Peer.cpp.

bool Peer::handshakeInitiator ( ) [private]

Definition at line 167 of file Peer.cpp.

Definition at line 267 of file Peer.cpp.

bool Peer::isInitiator ( ) const

Definition at line 574 of file Peer.cpp.

void Peer::notifyHook ( Command cmd) [private]

Definition at line 298 of file Peer.cpp.

void Peer::recv_array ( char *  value,
int  len 
)

Definition at line 513 of file Peer.cpp.

void Peer::recv_dummy ( int  len)

Definition at line 552 of file Peer.cpp.

short Peer::recv_int16 ( )

Definition at line 486 of file Peer.cpp.

Definition at line 472 of file Peer.cpp.

char Peer::recv_int8 ( )

Definition at line 500 of file Peer.cpp.

void Peer::recv_vls8 ( char *  value,
int  max = -1 
)

Definition at line 529 of file Peer.cpp.

string Peer::recv_vls8 ( )

Definition at line 546 of file Peer.cpp.

Definition at line 412 of file Peer.cpp.

void Peer::registerCommandCreator ( int  id,
cmd_creator_f  creator 
) [static]

Definition at line 234 of file Peer.cpp.

void Peer::send_array ( const char *  value,
int  len 
)

Definition at line 508 of file Peer.cpp.

void Peer::send_int16 ( short  value)

Definition at line 480 of file Peer.cpp.

void Peer::send_int32 ( int  value)

Definition at line 466 of file Peer.cpp.

void Peer::send_int8 ( char  value)

Definition at line 494 of file Peer.cpp.

void Peer::send_vls8 ( const char *  value)

Definition at line 520 of file Peer.cpp.

void Peer::send_vls8 ( const string &  value)

Definition at line 542 of file Peer.cpp.

Command * Peer::sendCommand ( Command command)

Definition at line 370 of file Peer.cpp.

void Peer::setCallback ( MasaNetCallbacks callback)

Definition at line 570 of file Peer.cpp.

void Peer::setLocalAddress ( const string &  publicAddress)

Definition at line 352 of file Peer.cpp.

void Peer::setLocalType ( int  localType)

Definition at line 328 of file Peer.cpp.

string Peer::toString ( )

Definition at line 201 of file Peer.cpp.

Definition at line 154 of file Peer.cpp.

Definition at line 281 of file Peer.cpp.


Member Data Documentation

Definition at line 111 of file Peer.hpp.

map< int, cmd_creator_f > Peer::cmdCreators [static, private]

Definition at line 130 of file Peer.hpp.

bool Peer::connected [private]

Definition at line 123 of file Peer.hpp.

int Peer::connectionType [private]

Definition at line 128 of file Peer.hpp.

bool Peer::error [private]

Definition at line 124 of file Peer.hpp.

pthread_cond_t Peer::handshakeCond [private]

Definition at line 115 of file Peer.hpp.

bool Peer::handshakeDone [private]

Definition at line 122 of file Peer.hpp.

bool Peer::hasStaticEvent = false [static, private]

Definition at line 153 of file Peer.hpp.

map<pthread_t, Command*> Peer::hookCommand [private]

Definition at line 133 of file Peer.hpp.

map<pthread_t, int> Peer::hookSerial [private]

Definition at line 134 of file Peer.hpp.

map<int, set<pthread_t> > Peer::hookThreads [private]

Definition at line 132 of file Peer.hpp.

bool Peer::initiator [private]

Definition at line 121 of file Peer.hpp.

string Peer::localAddress [private]

Definition at line 138 of file Peer.hpp.

string Peer::localId [private]

Definition at line 136 of file Peer.hpp.

int Peer::localType [private]

Definition at line 141 of file Peer.hpp.

pthread_mutex_t Peer::mutex [private]

Definition at line 113 of file Peer.hpp.

string Peer::remoteAddress [private]

Definition at line 139 of file Peer.hpp.

string Peer::remoteId [private]

Definition at line 137 of file Peer.hpp.

int Peer::remoteType [private]

Definition at line 140 of file Peer.hpp.

pthread_cond_t Peer::responseCond [private]

Definition at line 114 of file Peer.hpp.

Definition at line 59 of file Peer.hpp.

int Peer::serial [private]

Definition at line 125 of file Peer.hpp.

int Peer::socket [private]

Definition at line 120 of file Peer.hpp.

timeval Peer::staticEvent [static, private]

Definition at line 154 of file Peer.hpp.

float Peer::timeout [private]

Definition at line 126 of file Peer.hpp.


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