FREEDM DGI
Public Types | Public Member Functions | Private Attributes | List of all members
freedm::broker::CConnection Class Reference

Represents a single outgoing connection to a client.

#include <CConnection.hpp>

Inheritance diagram for freedm::broker::CConnection:

Public Types

typedef boost::shared_ptr< CConnectionConnectionPtr
 

Public Member Functions

 CConnection (std::string uuid, boost::asio::ip::udp::endpoint endpoint)
 Construct a CConnection to a peer. More...
 
 ~CConnection ()
 Destructor. More...
 
void ChangePhase (bool newround)
 Allows protocols to peform an action when a phase ends. More...
 
int GetReliability () const
 Get the connection reliability for DCUSTOMNETWORK. More...
 
bool GetStopped ()
 Tests to see if the protocol is stopped. More...
 
std::string GetUUID () const
 Gets the UUID of the peer for this connection. More...
 
void OnReceive ()
 Performs an action based on receiving a Protocol Message Window. More...
 
bool Receive (const ProtocolMessage &msg)
 Handles messages from the peer. More...
 
void ReceiveACK (const ProtocolMessage &msg)
 Handles acknowledgement messages from the peer. More...
 
void Send (const ModuleMessage &msg)
 Puts a message into the channel. More...
 
void SetReliability (int r)
 Set the connection reliability for DCUSTOMNETWORK. More...
 
void Stop ()
 Stop all asynchronous operations associated with the CConnection. More...
 

Private Attributes

boost::shared_ptr< IProtocolm_protocol
 The network protocol to use for sending/receiving messages. More...
 

Member Typedef Documentation

Constructor & Destructor Documentation

freedm::broker::CConnection::CConnection ( std::string  uuid,
boost::asio::ip::udp::endpoint  endpoint 
)

CConnection::CConnection

Description:
Create a connection to one particular peer. Initializes the selected message protocol used to deliver messages.
Parameters
uuidthe UUID of the peer to connect to
endpointThe target to send the messages to for this connection.
freedm::broker::CConnection::~CConnection ( )

Member Function Documentation

void freedm::broker::CConnection::ChangePhase ( bool  newround)

CConnection::ChangePhase

Description:
An event that gets called when the broker changes the current phase.
Precondition:
None
Postcondition:
The protocol's ChangePhase event is called.
Parameters
newroundIf true, the phase change is also the start of an entirely new round.
int freedm::broker::CConnection::GetReliability ( ) const

CConnection::GetReliability

Description:
Get the connection reliability for DCUSTOMNETWORK
Precondition:
None
Postcondition:
None
Returns
percentage of packets that are allowed through
bool freedm::broker::CConnection::GetStopped ( )

CConnection::GetStopped

Description:
Returns true if the underlying protocol has been stopped.
Returns
True if the underlying protocol is stopped.
std::string freedm::broker::CConnection::GetUUID ( ) const

CConnection::GetUUID

Description:
Gets the UUID of the DGI on the other end of this connection.
Precondition:
None
Postcondition:
None
Returns
the peer's UUID
void freedm::broker::CConnection::OnReceive ( )

CConnection::OnReceive

Description:
Handles performing some action after processing a received window.
Precondition:
None
Postcondition:
Call's the protocol's OnReceive method.
bool freedm::broker::CConnection::Receive ( const ProtocolMessage &  msg)

CConnection::Receive

Description:
Handler for receiving a non-ACK message from the peer
Precondition:
Initialized connection.
Postcondition:
Calls the protocol's Receive method.
Parameters
msgThe message received from the peer.
void freedm::broker::CConnection::ReceiveACK ( const ProtocolMessage &  msg)

CConnection::ReceiveACK

Description:
Handler for recieving acknowledgments from the peer.
Precondition:
Initialized connection.
Postcondition:
Calls the protocol's ReceiveACK function
Parameters
msgThe received acknowledge message.
void freedm::broker::CConnection::Send ( const ModuleMessage &  msg)

CConnection::Send

Description:
Passes a message to the protocol to deliver it to the intended recipient. If the intended recipient is this process, the delivery is done directly without the protocol.
Precondition:
None.
Postcondition:
The message is scheduled to be delivered.
Parameters
msgThe message to write to the channel.
void freedm::broker::CConnection::SetReliability ( int  r)

CConnection::SetReliability

Description:
Set the connection reliability for DCUSTOMNETWORK.
Parameters
rbetween 0 and 100 – 0 meaning all packets are artifically dropped. 100 means no packets are artifically dropped.
Precondition:
The DGI has been compiled with DCUSTOMNETWORK
Postcondition:
The reliability of the connection is changed
void freedm::broker::CConnection::Stop ( )

CConnection::Stop

Description:
Stops the protocol associated with this connection.
Precondition:
None.
Postcondition:
The message protocol's Stop method has been called.

Member Data Documentation

boost::shared_ptr<IProtocol> freedm::broker::CConnection::m_protocol
private

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