Description
Describe the issue
The documentation for awsiot.mqtt5_client_builder
describes common arguments for all builder functions. The on_publish_received
argument indicates:
Callback invoked for all publish packets received by client.
The function should take the following arguments and return nothing:
- publish_packet (awscrt.mqtt5.PublishPacket): Publish Packet received from the server.
Taking a look at the source code here, we can see a ClientOptions
instance instantiated if not provided:
client_options = _get(kwargs, 'client_options')
if client_options is None:
client_options = awscrt.mqtt5.ClientOptions(
host_name=_get(kwargs, 'endpoint')
)
Later on in the same function, here we can see that the on_publish_received
callback is set on the client_options
:
if client_options.on_publish_callback_fn is None:
client_options.on_publish_callback_fn = _get(kwargs, 'on_publish_received')
However, if we look at the documentation for on_publish_callback_fn
in awscrt
:
- on_publish_callback_fn (Callable[[PublishReceivedData],]) – Callback for all publish packets received by client.
In conclusion
awsiotsdk
specifies the callback input asawscrt.mqtt5.PublishPacket
- but
awscrt
specifies the callback input asawscrt.mqtt5.PublishReceivedData
Based on the other callbacks, I'm guessing awsiotsdk
documentation/type hinting is incorrect and the callback will receive PublishReceivedData
, not PublishPacket
(note that PublishReceivedData
is a dataclass
with only one field: publish_packet
which is hinted as a PublishPacket
instance).