Ejemplo n.º 1
0
    def from_bytes(cls, bytes_):
        assert type(bytes_) == bytes
        obj = cls()

        _raw_data = bytes(bytes_)

        obj.type, obj.dup, obj.qos, obj.retain, obj.length, remaining_data \
            = MQTTUtils.strip_fixed_header(_raw_data)

        assert obj.type == obj._message_type
        obj._decode_data(remaining_data)

        # The raw_data already corresponds to the obj field data. We change it
        # back to false to avoid encoding the data again upon raw_data lookup.
        obj._raw_data = _raw_data
        obj._pending_update = False

        return obj