Unit of all communication within and between peers. More...
Public Types | |
|
typedef boost::shared_ptr < Message > | SharedPtr |
Public Member Functions | |
Ctors & Dtors | |
| Message () | |
| Default contructor. | |
| Message (Message &a_Message) | |
| Copy constructor. | |
| Message (const std::string &a_fromService, const std::string &a_toService, const std::string &a_operation) | |
| Constructor to initialize header. | |
| Message (uint8_bt *a_buffer, uint64_bt a_buflen) | |
| Constructor for un-serialization. | |
| virtual | ~Message () |
| Destructor. | |
Serialization Functions | |
| void | flatten (Data::RawData::SharedPtr &a_data) |
| Serialize message to a RawData block. | |
Operators | |
| Message & | operator= (Message &a_message) |
| Assignment operator. | |
| Data::VariantRow & | operator[] (const std::string &a_index) |
| operator[] | |
Setters & Getters | |
| const std::string & | getFromService () const |
| Returns which service sent this messsage. | |
| void | setFromService (const std::string &a_fromService) |
| Set the caller service of this message. | |
| const Tonido::Data::PeerID & | getToPeerID (void) const |
| Gets to whom the message is being sent to. | |
| void | setToPeerID (const Tonido::Data::PeerID &a_toPeerID) |
| Sets to whom the message is being sent to. | |
| const Tonido::Data::PeerID & | getFromPeerID (void) const |
| Gets the PeerID who sent this message. | |
| void | setFromPeerID (const Tonido::Data::PeerID &a_fromPeerID) |
| Sets the PeerID from whom this message comes from. | |
| const std::string & | getVersion (void) const |
| Gets the Message Version. | |
| const std::string & | getToService (void) const |
| Gets to whom the message is going to. | |
| void | setToService (const std::string &a_toService) |
| Sets to whom the message is going to. | |
| uint32_bt | getFlags (void) const |
| Returns the message flags of this message. | |
| void | setFlags (uint16_bt a_flags) |
| Sets the message flag of this message. | |
| const std::string & | getOperation (void) const |
| Get Operation of this message. | |
| void | setOperation (const std::string &a_operation) |
| Sets the Operation of this message. | |
| uint32_bt | getSeqNumber (void) const |
| Monotically increasing sequence number for this message. | |
| void | setRawData (const char *i_Buffer, uint64_bt i_BufferLength) |
| Sets the payload that is part of this message. | |
| void | setRawData (const Data::RawData::SharedPtr &a_rawData) |
| Sets the payload that is part of this message. | |
| uint64_bt | getRawDataLen (void) const |
| Get raw data length in message object. | |
| uint8_bt * | getRawData (void) const |
| Get raw data stored in message object. | |
| uint64_bt | messageLength (void) |
| Get Message length. | |
| Data::VariantTable & | getVariantTable () |
| Returns the variant table associated with this message. | |
| const AuthKey & | getAuthKey () |
| Returns the Auth Key associated with this message. | |
| void | setAuthKey (const AuthKey &a_authKey) |
| Sets the Auth Key associated with this message. | |
| void | setCount (uint32_bt a_count) |
| Setters and Getters for Utility Counters. | |
| uint32_bt | getCount () const |
Unit of all communication within and between peers.
The following is message serialization format in memory
0 +------------------------------------+
| EyeCatcher#1 (0xBEEFCODE) |
4 +------------------------------------+
| Version |
8 +------------------------------------+
| Flags |
12 +------------------------------------+
| Sequence # |
16 +------------------------------------+
| Reserved |
20 +------------------------------------+
| From Service Length |
24 +------------------------------------+
| From Service Data(*) |
x +------------------------------------+
| To Service Length |
+4 +------------------------------------+
| To Service Data(*) |
x +------------------------------------+
| From PeerID(*) |
x +------------------------------------+
| To PeerID(*) |
x +------------------------------------+
| Operation Data Length |
+4 +------------------------------------+ .
| Operation Data(*) |
+4 +------------------------------------+
| Raw Data Length |
+12 +------------------------------------+
| Fn Map Raw Data Length |
+16 +------------------------------------+
| Raw Data (*) |
x +------------------------------------+
| EyeCatcher#2(0xDEADC0DE) |
+4 +------------------------------------+
| Fn Map Raw Data(*) |
x +------------------------------------+
| EyeCatcher#3(0xC0DEDEAD) |
+4 +------------------------------------+
| Tonido::Message::Message | ( | ) |
Default contructor.
Just create object with no data
| Tonido::Data::Message::Message | ( | Message & | a_Message | ) |
Copy constructor.
Create a new object from another message object
| Tonido::Message::Message | ( | const std::string & | a_fromService, |
| const std::string & | a_toService, | ||
| const std::string & | a_operation | ||
| ) |
Constructor to initialize header.
Create a new message with header filled in but without a data
| Tonido::Message::Message | ( | uint8_bt * | a_buffer, |
| uint64_bt | a_buflen | ||
| ) |
Constructor for un-serialization.
Create a Message object from a serialized buffer
| Tonido::Message::~Message | ( | ) | [virtual] |
Destructor.
Destructor that will delete m_pRawDataBuf, m_pRawDataBuf, m_pTraceBuf
| void Tonido::Message::flatten | ( | Data::RawData::SharedPtr & | a_data | ) |
Serialize message to a RawData block.
the buffer must be allocated to hold message.
| const Tonido::Data::PeerID& Tonido::Data::Message::getFromPeerID | ( | void | ) | const |
Gets the PeerID who sent this message.
| const std::string& Tonido::Data::Message::getFromService | ( | ) | const |
Returns which service sent this messsage.
| const std::string& Tonido::Data::Message::getOperation | ( | void | ) | const |
Get Operation of this message.
| uint8_bt* Tonido::Data::Message::getRawData | ( | void | ) | const |
Get raw data stored in message object.
Return pointer to the raw data stored
| uint64_bt Tonido::Data::Message::getRawDataLen | ( | void | ) | const |
Get raw data length in message object.
Return raw data length
| uint32_bt Tonido::Data::Message::getSeqNumber | ( | void | ) | const |
Monotically increasing sequence number for this message.
return the seq number value of this message
| const Tonido::Data::PeerID& Tonido::Data::Message::getToPeerID | ( | void | ) | const |
Gets to whom the message is being sent to.
Note that for local messaging, you don't need to set the to peer id
| const std::string& Tonido::Data::Message::getVersion | ( | void | ) | const |
Gets the Message Version.
Note: The format of the message is of the form major.minor.patch.revision
| uint64_bt Tonido::Message::messageLength | ( | void | ) |
Get Message length.
Calculate header + data length
Assignment operator.
The message passed in will be replicated and the a reference will be returned
| Data::VariantRow& Tonido::Data::Message::operator[] | ( | const std::string & | a_index | ) |
operator[]
Accesses the appropriate message section
| [in] | a_index | of the message section to access |
| void Tonido::Data::Message::setFromPeerID | ( | const Tonido::Data::PeerID & | a_fromPeerID | ) |
| void Tonido::Data::Message::setFromService | ( | const std::string & | a_fromService | ) |
Set the caller service of this message.
| a_fromService | the name of the service who sent this message |
| void Tonido::Message::setRawData | ( | const char * | i_Buffer, |
| uint64_bt | i_BufferLength | ||
| ) |
Sets the payload that is part of this message.
The user supplied buffer will be copied to a new buffer and will be deleted when this message is destroyed.
| void Tonido::Data::Message::setRawData | ( | const Data::RawData::SharedPtr & | a_rawData | ) |
Sets the payload that is part of this message.
The data is copied into the Message
| void Tonido::Data::Message::setToPeerID | ( | const Tonido::Data::PeerID & | a_toPeerID | ) |
Sets to whom the message is being sent to.
| a_toPeerID | ID of the peer to whom the message is being sent to |