diff --git a/src/ngcft1.cpp b/src/ngcft1.cpp index 69fdd22..909e233 100644 --- a/src/ngcft1.cpp +++ b/src/ngcft1.cpp @@ -132,6 +132,13 @@ void NGCFT1::updateSendTransfer(float time_delta, uint32_t group_number, uint32_ if (tf.inits_sent >= 3) { // delete, timed out 3 times std::cerr << "NGCFT1 warning: ft init timed out, deleting\n"; + dispatch( + NGCFT1_Event::send_done, + Events::NGCFT1_send_done{ + group_number, peer_number, + static_cast(idx), + } + ); tf_opt.reset(); } else { // timed out, resend @@ -158,8 +165,14 @@ void NGCFT1::updateSendTransfer(float time_delta, uint32_t group_number, uint32_ if (tf.time_since_activity >= sending_give_up_after) { // no ack after 30sec, close ft - // TODO: notify app std::cerr << "NGCFT1 warning: sending ft in progress timed out, deleting\n"; + dispatch( + NGCFT1_Event::send_done, + Events::NGCFT1_send_done{ + group_number, peer_number, + static_cast(idx), + } + ); // clean up cca tf.ssb.for_each(time_delta, [&](uint16_t id, const std::vector& data, float& time_since_activity) { diff --git a/src/ngcft1.hpp b/src/ngcft1.hpp index 131f5c7..360a827 100644 --- a/src/ngcft1.hpp +++ b/src/ngcft1.hpp @@ -67,14 +67,34 @@ namespace Events { size_t data_size; }; + struct NGCFT1_recv_done { + uint32_t group_number; + uint32_t peer_number; + + uint8_t transfer_id; + // TODO: reason + }; + + struct NGCFT1_send_done { + uint32_t group_number; + uint32_t peer_number; + + uint8_t transfer_id; + // TODO: reason + }; + } // Events enum class NGCFT1_Event : uint8_t { recv_request, recv_init, + recv_data, send_data, + recv_done, + send_done, + MAX }; @@ -84,6 +104,8 @@ struct NGCFT1EventI { virtual bool onEvent(const Events::NGCFT1_recv_init&) { return false; } virtual bool onEvent(const Events::NGCFT1_recv_data&) { return false; } virtual bool onEvent(const Events::NGCFT1_send_data&) { return false; } // const? + virtual bool onEvent(const Events::NGCFT1_recv_done&) { return false; } + virtual bool onEvent(const Events::NGCFT1_send_done&) { return false; } }; using NGCFT1EventProviderI = EventProviderI;