shamblett / coap

A Coap package for dart
Other
16 stars 13 forks source link

Fix timeout/max retransmission handling #137

Closed JKRhb closed 1 year ago

JKRhb commented 1 year ago

This PR provides a solution for the bug uncovered by @shamblett in https://github.com/shamblett/coap/issues/132#issuecomment-1288068964. The filtering logic is now moved inside a StreamTransformer object, which adds exceptions to the stream on timeout or cancellation. Similar to your suggestion in the issue, the relevant events are pre-filtered using a new CoapCompletionEvent interface that is "implemented" by the CoapResponse, CoapRequestTimeoutException, and CoapRequestCancellationException classes. Lastly, the PR applies minor refactoring to the matching of the original request and relevant responses.

JKRhb commented 1 year ago

Hmm. I just noticed that the cancellation event should actually not cause an exception to be added to the stream. I will adjust the PR a little.