RSB  0.19.0
rsb::transport::socket::BusConnection Class Reference

Instances of this class implement connections to a socket-based bus. More...

#include <BusConnection.h>

Inheritance diagram for rsb::transport::socket::BusConnection:
Inheritance graph
Collaboration diagram for rsb::transport::socket::BusConnection:
Collaboration graph

Public Types

typedef boost::shared_ptr< boost::asio::ip::tcp::socket > SocketPtr
 

Public Member Functions

 BusConnection (BusPtr bus, SocketPtr socket, bool client, bool tcpNoDelay=false)
 
 ~BusConnection ()
 
void shutdown ()
 
void startReceiving ()
 
void sendEvent (EventPtr event, const std::string &wireSchema)
 
virtual const std::string getTransportURL () const
 

Private Types

typedef boost::weak_ptr< BusWeakBusPtr
 

Private Member Functions

void performSafeCleanup (const std::string &context)
 
void receiveEvent ()
 
void handleReadLength (const boost::system::error_code &error, size_t bytesTransferred)
 
void handleReadBody (const boost::system::error_code &error, size_t bytesTransferred, size_t expected)
 
void printContents (std::ostream &stream) const
 
void disconnect ()
 

Private Attributes

rsc::logging::LoggerPtr logger
 
SocketPtr socket
 
WeakBusPtr bus
 
volatile bool disconnecting
 
volatile bool activeShutdown
 
boost::recursive_mutex mutex
 
protocol::Notification notification
 
std::string lengthReceiveBuffer
 
std::string messageReceiveBuffer
 
std::string lengthSendBuffer
 
std::string messageSendBuffer
 

Detailed Description

Instances of this class implement connections to a socket-based bus.

The basic operations provided by this class are receiving an event by calling receiveEvent and submitting an event to the bus by calling sendEvent.

In a process which acts as a client for a particular bus, a single instance of this class is connected to the remote bus server and provides access to the bus for all participants in the process.

A process which acts as the server for a particular bus, manages (via the BusServer class) one BusConnection object for each client (remote process) connected to the bus.

This class is not thread-safe.

Author
jmoringe

Definition at line 74 of file BusConnection.h.

Member Typedef Documentation

typedef boost::shared_ptr<boost::asio::ip::tcp::socket> rsb::transport::socket::BusConnection::SocketPtr

Definition at line 77 of file BusConnection.h.

typedef boost::weak_ptr<Bus> rsb::transport::socket::BusConnection::WeakBusPtr
private

Definition at line 95 of file BusConnection.h.

Constructor & Destructor Documentation

rsb::transport::socket::BusConnection::BusConnection ( BusPtr  bus,
SocketPtr  socket,
bool  client,
bool  tcpNoDelay = false 
)

Definition at line 60 of file BusConnection.cpp.

References lengthReceiveBuffer, lengthSendBuffer, and logger.

rsb::transport::socket::BusConnection::~BusConnection ( )

Definition at line 87 of file BusConnection.cpp.

References performSafeCleanup().

Here is the call graph for this function:

Member Function Documentation

void rsb::transport::socket::BusConnection::disconnect ( )
private

Definition at line 105 of file BusConnection.cpp.

References disconnecting, logger, mutex, and socket.

Referenced by performSafeCleanup().

Here is the caller graph for this function:

const std::string rsb::transport::socket::BusConnection::getTransportURL ( ) const
virtual

Definition at line 287 of file BusConnection.cpp.

References socket.

void rsb::transport::socket::BusConnection::handleReadBody ( const boost::system::error_code &  error,
size_t  bytesTransferred,
size_t  expected 
)
private

Definition at line 239 of file BusConnection.cpp.

References bus, disconnecting, event, logger, notification, rsb::transport::socket::notificationToEvent(), performSafeCleanup(), and receiveEvent().

Referenced by handleReadLength().

Here is the call graph for this function:

Here is the caller graph for this function:

void rsb::transport::socket::BusConnection::handleReadLength ( const boost::system::error_code &  error,
size_t  bytesTransferred 
)
private

Definition at line 188 of file BusConnection.cpp.

References activeShutdown, disconnecting, handleReadBody(), lengthReceiveBuffer, logger, messageReceiveBuffer, mutex, performSafeCleanup(), rsb::transport::socket::safeSocketExceptionString(), shutdown(), and socket.

Referenced by receiveEvent().

Here is the call graph for this function:

Here is the caller graph for this function:

void rsb::transport::socket::BusConnection::performSafeCleanup ( const std::string &  context)
private

Definition at line 156 of file BusConnection.cpp.

References bus, disconnect(), disconnecting, logger, and rsb::transport::socket::safeSocketExceptionString().

Referenced by handleReadBody(), handleReadLength(), and ~BusConnection().

Here is the call graph for this function:

Here is the caller graph for this function:

void rsb::transport::socket::BusConnection::printContents ( std::ostream &  stream) const
private

Definition at line 278 of file BusConnection.cpp.

References socket.

void rsb::transport::socket::BusConnection::receiveEvent ( )
private

Definition at line 180 of file BusConnection.cpp.

References handleReadLength(), lengthReceiveBuffer, and socket.

Referenced by handleReadBody(), and startReceiving().

Here is the call graph for this function:

Here is the caller graph for this function:

void rsb::transport::socket::BusConnection::sendEvent ( EventPtr  event,
const std::string &  wireSchema 
)

Definition at line 121 of file BusConnection.cpp.

References activeShutdown, rsb::transport::socket::eventToNotification(), lengthSendBuffer, logger, messageSendBuffer, mutex, notification, and socket.

Here is the call graph for this function:

void rsb::transport::socket::BusConnection::shutdown ( )

Definition at line 93 of file BusConnection.cpp.

References activeShutdown, logger, mutex, and socket.

Referenced by handleReadLength().

Here is the caller graph for this function:

void rsb::transport::socket::BusConnection::startReceiving ( )

Definition at line 117 of file BusConnection.cpp.

References receiveEvent().

Here is the call graph for this function:

Member Data Documentation

volatile bool rsb::transport::socket::BusConnection::activeShutdown
private

Definition at line 104 of file BusConnection.h.

Referenced by handleReadLength(), sendEvent(), and shutdown().

WeakBusPtr rsb::transport::socket::BusConnection::bus
private

Definition at line 101 of file BusConnection.h.

Referenced by handleReadBody(), and performSafeCleanup().

volatile bool rsb::transport::socket::BusConnection::disconnecting
private

Definition at line 103 of file BusConnection.h.

Referenced by disconnect(), handleReadBody(), handleReadLength(), and performSafeCleanup().

std::string rsb::transport::socket::BusConnection::lengthReceiveBuffer
private

Definition at line 110 of file BusConnection.h.

Referenced by BusConnection(), handleReadLength(), and receiveEvent().

std::string rsb::transport::socket::BusConnection::lengthSendBuffer
private

Definition at line 114 of file BusConnection.h.

Referenced by BusConnection(), and sendEvent().

rsc::logging::LoggerPtr rsb::transport::socket::BusConnection::logger
private
std::string rsb::transport::socket::BusConnection::messageReceiveBuffer
private

Definition at line 111 of file BusConnection.h.

Referenced by handleReadLength().

std::string rsb::transport::socket::BusConnection::messageSendBuffer
private

Definition at line 115 of file BusConnection.h.

Referenced by sendEvent().

boost::recursive_mutex rsb::transport::socket::BusConnection::mutex
private

Definition at line 106 of file BusConnection.h.

Referenced by disconnect(), handleReadLength(), sendEvent(), and shutdown().

protocol::Notification rsb::transport::socket::BusConnection::notification
private

Definition at line 109 of file BusConnection.h.

Referenced by handleReadBody(), and sendEvent().

SocketPtr rsb::transport::socket::BusConnection::socket
private

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