MIRA
|
Connection class for incoming connections. More...
#include <fw/RemoteConnection.h>
Public Types | |
typedef std::map< std::string, Typename > | ChannelTypeMap |
typedef std::set< std::string > | StringSet |
typedef std::map< std::string, SendData > | ChannelSendMap |
typedef std::set< std::string > | MetaSet |
typedef std::list< AuthorityDescription > | AuthorityDescriptions |
Public Member Functions | |
template<typename Reflector > | |
void | reflect (Reflector &r) |
virtual void | start () |
Implementation of RemoteConnection. More... | |
boost::asio::ip::tcp::endpoint & | getEndpoint () |
Returns a reference to the endpoint of the remote peer. More... | |
boost::asio::ip::tcp::socket & | getSocket () |
Returns the network socket of this connection. More... | |
void | stop () |
Close the socket. More... | |
void | onConnect (bool enablePTPTimeSync, bool enablePingTimeout) |
Called by RemoteModule::onIncomingConnected/onOutgoingConnected. More... | |
bool | isPTPSyncEnabled () |
Is synchronization of clocks via PTP enabled? More... | |
bool | isPingTimeoutEnabled () |
Is ping timeout enabled? More... | |
void | startTimeSync () |
Create a timer to frequently call syncTime. More... | |
bool | isSynchronized () const |
synchronizeFrameworks() was executed. More... | |
void | unpublishChannel (const std::string &channel) |
Notifies the connected framework that we no longer have a publisher for the given channel. More... | |
void | migrateUnit (const std::string &id) |
Send a request to the connected framework to transfer ownership of a unit to this framework. More... | |
bool | hasAuthority (const std::string &id) const |
Check if a authority with given full id exists in the connected framework. More... | |
template<typename BufferSequence > | |
void | write (const BufferSequence &buffers) |
Send data in the buffers to the connected framework. More... | |
UUID | getRemoteID () const |
std::string | getGlobalID () const |
void | setAuthority (std::unique_ptr< Authority > auth) |
const std::string & | getFrameworkID () const |
const KnownFramework & | getAddress () const |
void | setAddress (const KnownFramework &addr) |
void | setAutoReconnect (bool autoReconnect) |
Class const & | getClass () const |
call the virtual internalGetClass(). More... | |
Static Public Member Functions | |
static PseudoClass const & | CLASS () |
Protected Types | |
enum | AuthState { AUTHSTATE_NONE, AUTHSTATE_CONNECTING, AUTHSTATE_AUTHENTICATING, AUTHSTATE_ACCEPTED, AUTHSTATE_DENIED } |
typedef std::pair< FrameworkMessageType, Buffer< uint8 > > | RPCMessage |
Protected Member Functions | |
RemoteIncomingConnection () | |
virtual void | onDisconnect () |
Implementation of RemoteConnection. More... | |
void | handleReadHeader (const boost::system::error_code &error) |
void | handleReadMessage (const boost::system::error_code &error) |
virtual void | publishChannels (const ChannelTypeMap &channels) |
Notifies the connected framework that we have at least one publisher for each of the channels in the channels map. More... | |
virtual void | subscribeChannel (const std::string &channelID, const ServiceLevel &serviceLevel) |
Notify the connected remote frameworks that we have a subscriber for the given channel (assuming it has a publisher for it). More... | |
virtual void | publishAuthorities (const AuthorityDescriptions &authorities) |
Notifies the connected framework that the authorities in the authorities map exist in our framework. More... | |
virtual void | unpublishAuthorities (const AuthorityDescriptions &authorities) |
Notifies the connected framework that the authorities in the authorities map do not longer exist in our framework. More... | |
virtual void | publishServicesFiltered (const StringSet &services) |
virtual void | publishServices (const StringSet &services) |
Notifies the connected framework that the services in the services set exist in our framework. More... | |
virtual void | unpublishServicesFiltered (const StringSet &services) |
virtual void | unpublishServices (const StringSet &services) |
Notifies the connected framework that the services in the services set do not longer exist in our framework. More... | |
virtual void | sendData (ChannelRead< void > value, ServiceLevel &serviceLevel) |
virtual int | addBinaryFormatVersion (Buffer< uint8 > &data) |
virtual void | receivedPublishServiceMsg () |
virtual void | receivedRPCRequestMsg () |
virtual void | receivedRPCResponseMsg () |
virtual void | onWriteError (boost::system::system_error &e) |
Called when writing to the socket failed. Can be implemented in derived classes. More... | |
void | syncTime () |
Time synchronization between frameworks. More... | |
void | sendPTP () |
Sends a PTP command used for time synchronization between frameworks. More... | |
void | ping () |
Sends a ping command. More... | |
bool | hasPingTimeout () const |
Check if the connection incoming ping's are still alive. More... | |
void | writeMessage (FrameworkMessageType msg) |
Writes a message to the other framework. More... | |
template<typename Arg , typename... Args> | |
void | writeMessage (FrameworkMessageType msg, Arg &&arg, Args &&... args) |
Writes a message to the other framework. More... | |
template<typename BufferType > | |
void | writeMessageFromBuffer (FrameworkMessageType msg, const BufferType &buffer) |
Writes a message to the other framework. More... | |
template<typename DataType > | |
void | writeMessageFromData (FrameworkMessageType msg, const DataType &data) |
Writes a message to the other framework. More... | |
void | queueRPCMessage (FrameworkMessageType msg, Buffer< uint8 > &&answer) |
Queue an outgoing RPC request or RPC response to be transmitted in a separate thread. More... | |
void | valueChanged (ChannelRead< void > value, ServiceLevel &serviceLevel) |
Channel callback method that gets registered on each channel the connected framework subscribes. More... | |
void | parseMessage () |
Parses an incoming message (stored in mMessage) and calls the respective receivedXXX method. More... | |
void | receivedPTPFollowUp (uint64 timestamp) |
void | receivedPTPDelayResponse (uint64 timestamp) |
void | receivedPTPDelayRequest (uint64 timestamp) |
void | receivedPTPFinish () |
void | receivedSubscribeChannelRequest () |
void | receivedUnsubscribeChannelRequest (const std::string &channelID) |
void | receivedPublishChannelMsg () |
void | receivedUnpublishChannelMsg () |
void | receivedPublishAuthorityMsg () |
void | receivedUnpublishAuthorityMsg () |
void | receivedUnpublishServiceMsg () |
void | receivedWriteChannelMsg () |
void | receivedRequestMigrationMsg () |
void | receivedMigrationMsg () |
void | receivedMigrationSinkSuccessMsg () |
void | receivedMigrationSinkFailureMsg () |
void | receivedMigrationFinishedMsg () |
void | receivedTypeMetaMsg () |
void | receivedChannelMetaMsg () |
void | receivedPingMsg () |
void | synchronizeFrameworks () |
void | updateOutgoingStats (std::size_t size) |
bool | checkMessageHeader () const |
Returns true, if the message (header) is valid, i.e. More... | |
void | sendConnectDenied (const std::string &msg) |
void | sendRPCMessagesThread () |
void | processPingThread () |
void | checkPingTimeoutThread () |
void | sendChannelUpdatesThread () |
virtual Class const & | internalGetClass () const =0 |
Protected Attributes | |
boost::asio::ip::tcp::endpoint | mPeerEndpoint |
endpoint of the remote peer More... | |
KnownFramework | address |
The address of the connected framework. More... | |
UUID | remoteID |
The UUID of the connected framework. More... | |
std::string | frameworkID |
The ID/Name of the connected framework. More... | |
uint32 | remoteVersion |
The protocol version of the connected framework. More... | |
std::unique_ptr< Authority > | authority |
Our authority used for subscribing to data. More... | |
ChannelSendMap | subscriptions |
List of channels the connected framework is subscribed to + what was sent to them. More... | |
MetaSet | sentMetaInformation |
Set of type meta information already sent. More... | |
StringSet | publishedServices |
List of services of the connected framework. More... | |
Time | synchronizedTime |
Time when the connection was fully established (e.g. PTP synchronized) More... | |
bool | mEnablePTPSync |
PTP Sync enabled for this connection? More... | |
bool | mEnablePingTimeout |
Ping timeout enabled for this connection? More... | |
TimeOffsetCompensation | clockOffset |
The clock offset between us and the connected framework. More... | |
IOService | mService |
boost::asio::ip::tcp::socket | mSocket |
boost::condition_variable | mRPCMessagesCondition |
boost::mutex | mWriteMutex |
boost::mutex | mStopMutex |
TimerPtr | mSyncTimeTimer |
boost::thread | mSendRPCMessagesThread |
boost::thread | mProcessPingThread |
boost::thread | mCheckPingTimeoutThread |
boost::thread | mSendChannelUpdatesThread |
Time | mHeaderReceived |
FrameworkMessageHeader | mHeader |
Buffer< uint8 > | mMessage |
AuthState | mAuthState |
std::string | mAuthSignMsg |
bool | mPTPOutgoing |
Time | mPTPSyncLocal |
Time | mPTPSyncRemote |
Time | mPTPDelayLocal |
Time | mPTPDelayRemote |
Time | mLastPTP |
Time | mPingLastSend |
Time | mPingLastReceived |
boost::shared_ptr< MicroUnit > | mMigrationUnit |
std::string | mMigrationNS |
std::string | mMigrationID |
bool | mStopped |
boost::shared_ptr< RPCRemoteFinishHandler > | mRPCFinishHandler |
boost::shared_ptr< RPCRemoteRequestHandler > | mRPCRequestHandler |
std::map< std::string, boost::shared_ptr< RemoteAuthority > > | mRemoteAuthorities |
std::list< RPCMessage > | mOutgoingRPCMessages |
boost::mutex | mRPCMessagesMutex |
std::unordered_map< std::string, ServiceLevel > | mPendingChannelUpdates |
boost::mutex | mChannelUpdatesMutex |
Friends | |
class | RemoteConnectionPool |
class | ClassFactoryDefaultConstClassBuilder |
Connection class for incoming connections.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
inline |
|
virtual |
Implementation of RemoteConnection.
Reimplemented from RemoteConnection.
|
inline |
Returns a reference to the endpoint of the remote peer.
|
protectedvirtual |
Implementation of RemoteConnection.
Reimplemented from RemoteConnection.
|
protected |
|
protected |
|
protectedvirtualinherited |
Notifies the connected framework that we have at least one publisher for each of the channels in the channels map.
Implements RemoteConnection.
|
protectedvirtualinherited |
Notify the connected remote frameworks that we have a subscriber for the given channel (assuming it has a publisher for it).
Implements RemoteConnection.
|
protectedvirtualinherited |
Notifies the connected framework that the authorities in the authorities map exist in our framework.
Implements RemoteConnection.
|
protectedvirtualinherited |
Notifies the connected framework that the authorities in the authorities map do not longer exist in our framework.
Implements RemoteConnection.
|
protectedvirtualinherited |
|
protectedvirtualinherited |
Notifies the connected framework that the services in the services set exist in our framework.
Implements RemoteConnection.
|
protectedvirtualinherited |
|
protectedvirtualinherited |
Notifies the connected framework that the services in the services set do not longer exist in our framework.
Implements RemoteConnection.
|
protectedvirtualinherited |
Reimplemented from RemoteConnection.
|
protectedvirtualinherited |
Implements RemoteConnection.
|
protectedvirtualinherited |
Implements RemoteConnection.
|
protectedvirtualinherited |
Implements RemoteConnection.
|
protectedvirtualinherited |
Implements RemoteConnection.
|
inlineinherited |
Returns the network socket of this connection.
|
inherited |
Close the socket.
|
inherited |
Called by RemoteModule::onIncomingConnected/onOutgoingConnected.
Provides the RemoteModule settings for enabling PTP sync and ping timeout, which should be kept by the RemoteConnection through its lifetime.
|
inlineinherited |
Is synchronization of clocks via PTP enabled?
|
inlineinherited |
Is ping timeout enabled?
|
inherited |
Create a timer to frequently call syncTime.
Time sync must be completed at least once before data is transmitted (if ping timeout is enabled in the RemoteModule, time sync is automatically done in the ping thread and the timer should not be created).
|
inlineinherited |
synchronizeFrameworks() was executed.
The connection is fully established, time was synchronized at least once (if enabled and required) and authorities/channels/services have been published to the remote framework (unless monitor-only).
|
inherited |
Notifies the connected framework that we no longer have a publisher for the given channel.
|
inherited |
Send a request to the connected framework to transfer ownership of a unit to this framework.
|
inherited |
Check if a authority with given full id exists in the connected framework.
|
inlineinherited |
Send data in the buffers to the connected framework.
[in] | buffers | The data to send |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineprotectedvirtualinherited |
Called when writing to the socket failed. Can be implemented in derived classes.
Reimplemented in RemoteOutgoingConnectionBase.
|
protectedinherited |
Time synchronization between frameworks.
For local connected frameworks the method synchronizeFrameworks will be called. For frameworks on remote hosts sendPTP will be called.
|
protectedinherited |
Sends a PTP command used for time synchronization between frameworks.
|
protectedinherited |
Sends a ping command.
This method ensures, that the ping is not send more than the configured interval in the RemoteModule.
|
protectedinherited |
Check if the connection incoming ping's are still alive.
|
inlineprotectedinherited |
Writes a message to the other framework.
This method takes just the message type.
|
inlineprotectedinherited |
Writes a message to the other framework.
This method takes the message type and a variable number of parameters that are sent within the message.
|
inlineprotectedinherited |
Writes a message to the other framework.
Instead of writing parameters into a buffer for generating the message, this method expects a buffer as parameter directly, e.g. created by serializing data.
|
inlineprotectedinherited |
Writes a message to the other framework.
Instead of writing the parameter into a buffer for generating the message, (as writeMessage does), this method uses the parameter memory location directly.
|
protectedinherited |
Queue an outgoing RPC request or RPC response to be transmitted in a separate thread.
msg must be either RPC_RESPONSE_MSG or RPC_REQUEST_MSG
|
protectedinherited |
Channel callback method that gets registered on each channel the connected framework subscribes.
When data in the channel changes it is sent to the connected framework.
|
protectedinherited |
Parses an incoming message (stored in mMessage) and calls the respective receivedXXX method.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Returns true, if the message (header) is valid, i.e.
if the specified message length does not exceed a max size and the message type is known. This is used to prevent Denial of Service attacks.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
inlineinherited |
call the virtual internalGetClass().
|
inlinestaticinherited |
|
protectedpure virtualinherited |
|
friend |
|
friend |
|
protected |
endpoint of the remote peer
|
protectedinherited |
The address of the connected framework.
|
protectedinherited |
The UUID of the connected framework.
|
protectedinherited |
The ID/Name of the connected framework.
|
protectedinherited |
The protocol version of the connected framework.
|
protectedinherited |
Our authority used for subscribing to data.
|
protectedinherited |
List of channels the connected framework is subscribed to + what was sent to them.
|
protectedinherited |
Set of type meta information already sent.
|
protectedinherited |
List of services of the connected framework.
|
protectedinherited |
Time when the connection was fully established (e.g. PTP synchronized)
|
protectedinherited |
PTP Sync enabled for this connection?
|
protectedinherited |
Ping timeout enabled for this connection?
|
protectedinherited |
The clock offset between us and the connected framework.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |