Skip to content

Conversation

redboltz
Copy link
Owner

The client's publish handler used to be called when pubrel is received.
I thought that it was the best way to avoid duplicate publish.
However, I found better way.
I introduced the std::set<std::uint16_t> that stores packet_id.
The member variable name is qos2_publish_handled_.
When publish is received, check qos2_publish_handled_.
If packet_id has already been stored, client's publish handler is not
called, but pubrec is sent to the client.
If packet_id is not stored, call the client's publish handler and
stores packet_id into qos2_publish_handled_.
When pubrel is received, the packet_id in qos2_publish_handled_ is
removed.

The client's publish handler used to be called when pubrel is received.
I thought that it was the best way to avoid duplicate publish.
However, I found better way.
I introduced the `std::set<std::uint16_t>` that stores packet_id.
The member variable name is qos2_publish_handled_.
When publish is received, check qos2_publish_handled_.
If packet_id has already been stored, client's publish handler is not
called, but pubrec is sent to the client.
If packet_id is not stored, call the client's publish handler and
stores packet_id into qos2_publish_handled_.
When pubrel is received, the packet_id in qos2_publish_handled_ is
removed.
@redboltz redboltz merged commit 8d67e2d into master Aug 22, 2016
@redboltz redboltz deleted the change_qos2_publish_handle_timing branch August 22, 2016 04:49
redboltz added a commit that referenced this pull request Aug 8, 2021
qos2_publish_handled_ was inserted and erased but not referenced.
When PUBLISH QoS2 packet is received, if qos2_publish_handled_ has the
packet_id then on_publish isn't called. (Exactly once delivery)

See #49.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant