TODO: write this.
More...
#include <Protocol.hh>
|
struct | Message |
| Data entity communicated by the connection to the designated protocol. More...
|
|
|
virtual char | getProtocolFlag () |
| Returns the byte sent in the message to indicate which protocol instance to call for interpretation and processing. More...
|
|
virtual void | processMessage (Message m) |
| Called by the sync node when data with this protocols flag has been received. More...
|
|
virtual void | lostPeer (size_t idx) |
| Called by the sync node when connection to one of the peers has been broken. More...
|
|
void | setSyncNode (SyncNode *sync_node) |
|
|
static const size_t | HEADER_LENGTH = Message().getHeader().size() |
|
◆ getConnectedPeers()
std::set< size_t > gramods::gmNetwork::Protocol::getConnectedPeers |
( |
| ) |
|
|
protected |
Convenience method for quering the SyncNode for the currently connected peers.
◆ getLocalPeerIdx()
size_t gramods::gmNetwork::Protocol::getLocalPeerIdx |
( |
| ) |
|
|
protected |
◆ getProtocolFlag()
virtual char gramods::gmNetwork::Protocol::getProtocolFlag |
( |
| ) |
|
|
inlinevirtual |
Returns the byte sent in the message to indicate which protocol instance to call for interpretation and processing.
Values 0-127 are reserved for internal protocols while values 128-255 may be used by application specific protocols.
Reimplemented in gramods::gmNetwork::RunSync, and gramods::gmNetwork::DataSync.
◆ lostPeer()
void gramods::gmNetwork::Protocol::lostPeer |
( |
size_t |
idx | ) |
|
|
virtual |
◆ processMessage()
void gramods::gmNetwork::Protocol::processMessage |
( |
Message |
m | ) |
|
|
virtual |
Called by the sync node when data with this protocols flag has been received.
The message is complete, as sent by the peer.
It should be assumed that the call is made from a non-main thread. Also, the method should return promptly and leave heavy processing to either another worker thread or to the main thread.
Reimplemented in gramods::gmNetwork::RunSync, and gramods::gmNetwork::DataSync.
◆ sendMessage()
void gramods::gmNetwork::Protocol::sendMessage |
( |
std::vector< char > |
data | ) |
|
|
protected |
Convenience method for creating a message and sending this to all peers.
◆ sync_node
SyncNode* gramods::gmNetwork::Protocol::sync_node |
|
protected |
The SyncNode instance this protocol communicates through or nullptr if it has gone out of scope.
Use sync_node_lock to avoid race condition on this pointer.
◆ sync_node_lock
std::mutex gramods::gmNetwork::Protocol::sync_node_lock |
|
protected |
Lock for synchronizing the sync_node pointer.
The documentation for this class was generated from the following files:
- /home/karlu/private/program/gramods/modules/gmNetwork/include/gmNetwork/Protocol.hh
- /home/karlu/private/program/gramods/modules/gmNetwork/src/Protocol.cpp