diff options
Diffstat (limited to 'common/message.h')
-rw-r--r-- | common/message.h | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/common/message.h b/common/message.h index 1d6ae8b..44343ae 100644 --- a/common/message.h +++ b/common/message.h @@ -1,6 +1,8 @@ #ifndef MESSAGE_H #define MESSAGE_H +#include "payload.h" + #include <boost/shared_ptr.hpp> #include <stdint.h> @@ -11,14 +13,8 @@ class Message { Message(); std::size_t deserialize_size; - - public: - typedef boost::shared_ptr<Message> p; - static p create(); - - //! Temporary payload. - std::string payload; + friend class ConnectionBase; //! Serialize message. std::pair<uint8_t*, std::size_t> serialize(); @@ -26,6 +22,22 @@ class Message { //! Deserialize message. std::size_t deserialize(uint8_t* data, std::size_t bytes); + Payload::Type payload_type; + Payload::Base* payload_data; + + public: + typedef boost::shared_ptr<Message> p; + + static p create(); + + //! Return payload type. + Payload::Type type(); + + //! Return reference to payload. + template <class T> + T& payload() { + return dynamic_cast<T&>(*payload_data); + } }; -#endif
\ No newline at end of file +#endif |