RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 disconnect ()
void startReceiving ()
void sendEvent (EventPtr event, const std::string &wireSchema)

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

Private Attributes

rsc::logging::LoggerPtr logger
SocketPtr socket
WeakBusPtr bus
volatile bool disconnecting
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 72 of file BusConnection.h.

Member Typedef Documentation

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

Definition at line 75 of file BusConnection.h.

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

Definition at line 91 of file BusConnection.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file BusConnection.cpp.

References lengthReceiveBuffer, lengthSendBuffer, and logger.

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

Definition at line 76 of file BusConnection.cpp.

References performSafeCleanup().

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 80 of file BusConnection.cpp.

References disconnecting, logger, and socket.

Referenced by performSafeCleanup().

Here is the caller graph for this function:

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

Definition at line 179 of file BusConnection.cpp.

References disconnecting, logger, messageReceiveBuffer, 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 149 of file BusConnection.cpp.

References disconnecting, handleReadBody(), lengthReceiveBuffer, logger, messageReceiveBuffer, performSafeCleanup(), 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 119 of file BusConnection.cpp.

References bus, disconnect(), disconnecting, and logger.

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 214 of file BusConnection.cpp.

References socket.

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

Definition at line 141 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 96 of file BusConnection.cpp.

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

Here is the call graph for this function:

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

Definition at line 92 of file BusConnection.cpp.

References receiveEvent().

Here is the call graph for this function:

Member Data Documentation

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

Definition at line 97 of file BusConnection.h.

Referenced by performSafeCleanup().

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

Definition at line 99 of file BusConnection.h.

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

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

Definition at line 103 of file BusConnection.h.

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

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

Definition at line 107 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 104 of file BusConnection.h.

Referenced by handleReadBody(), and handleReadLength().

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

Definition at line 108 of file BusConnection.h.

Referenced by sendEvent().

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

Definition at line 102 of file BusConnection.h.

Referenced by handleReadBody(), and sendEvent().

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

Definition at line 95 of file BusConnection.h.

Referenced by disconnect(), handleReadLength(), printContents(), receiveEvent(), and sendEvent().


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