Exemple #1
0
 bool operator==(const frame& a_, const frame& b_)
 {
   return a_.type() == b_.type() && a_.is_full() == b_.is_full() &&
          (!a_.is_full() ||
           (a_.kind() == b_.kind() &&
            a_.point_of_instantiation() == b_.point_of_instantiation())) &&
          a_.is_profiled() == b_.is_profiled() &&
          (!a_.is_profiled() ||
           (a_.time_taken() == b_.time_taken() &&
            a_.time_taken_ratio() == b_.time_taken_ratio()));
 }
            /// \brief Decode supplied \c frame into a \c pubrel packet.
            ///
            /// \see io_wally::protocol::decoder::packet_body_decoder::parse
            ///
            virtual std::shared_ptr<protocol::mqtt_packet> decode( const frame& frame ) const
            {
                using namespace io_wally::protocol;

                assert( frame.type( ) == packet::Type::PUBREL );

                // [MQTT-2.2.2-1] Flags in PUBREL MUST be 0010
                if ( ( frame.type_and_flags & 0x0F ) != 0x02 )
                    throw error::malformed_mqtt_packet{"[MQTT-2.2.2-1] Invalid flags in PUBREL packet."};

                // Parse variable header pubrel_header
                auto packet_id = uint16_t{0};
                std::tie( std::ignore, packet_id ) = decode_uint16( frame.begin, frame.end );

                return std::make_shared<protocol::pubrel>( packet_id );
            }