17 #ifndef DISCONNECTMESSAGE_HPP_
18 #define DISCONNECTMESSAGE_HPP_
23 #include <boost/format.hpp>
47 return "Internal error has been occurred";
49 return "Credentials have been revoked";
51 return (boost::format(
"Invalid Disconnect reason %1%") % (std::uint8_t) reason).str();
59 std::copy(reinterpret_cast<const std::uint8_t *>(header),
60 reinterpret_cast<const std::uint8_t *>(header + 2),
63 message_[3] = (std::uint8_t) reason_;
68 parseMessage(payload, size);
76 const std::vector<std::uint8_t>&
getRawMessage()
const {
return message_; }
79 void parseMessage(
const char *payload, std::uint16_t size)
81 if (!payload || !size) {
85 int code = *(payload + 1);
87 throw KaaException(boost::format(
"Bad Disconnect return code: %1%") % code);
93 std::vector<std::uint8_t> message_;
static std::string reasonToString(DisconnectReason reason)
DisconnectMessage(const char *payload, std::uint16_t size)
DisconnectMessage(DisconnectReason reason)
DisconnectReason getReason() const
std::string getMessage() const
static std::uint8_t createBasicHeader(std::uint8_t messageType, std::uint32_t length, char *message)
const std::vector< std::uint8_t > & getRawMessage() const