trigger send_done event

This commit is contained in:
Green Sky 2023-08-09 23:12:52 +02:00
parent 853a54a9b5
commit 6a802475c1
No known key found for this signature in database
2 changed files with 36 additions and 1 deletions

View File

@ -132,6 +132,13 @@ void NGCFT1::updateSendTransfer(float time_delta, uint32_t group_number, uint32_
if (tf.inits_sent >= 3) { if (tf.inits_sent >= 3) {
// delete, timed out 3 times // delete, timed out 3 times
std::cerr << "NGCFT1 warning: ft init timed out, deleting\n"; 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<uint8_t>(idx),
}
);
tf_opt.reset(); tf_opt.reset();
} else { } else {
// timed out, resend // 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) { if (tf.time_since_activity >= sending_give_up_after) {
// no ack after 30sec, close ft // no ack after 30sec, close ft
// TODO: notify app
std::cerr << "NGCFT1 warning: sending ft in progress timed out, deleting\n"; 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<uint8_t>(idx),
}
);
// clean up cca // clean up cca
tf.ssb.for_each(time_delta, [&](uint16_t id, const std::vector<uint8_t>& data, float& time_since_activity) { tf.ssb.for_each(time_delta, [&](uint16_t id, const std::vector<uint8_t>& data, float& time_since_activity) {

View File

@ -67,14 +67,34 @@ namespace Events {
size_t data_size; 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 } // Events
enum class NGCFT1_Event : uint8_t { enum class NGCFT1_Event : uint8_t {
recv_request, recv_request,
recv_init, recv_init,
recv_data, recv_data,
send_data, send_data,
recv_done,
send_done,
MAX MAX
}; };
@ -84,6 +104,8 @@ struct NGCFT1EventI {
virtual bool onEvent(const Events::NGCFT1_recv_init&) { return false; } 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_recv_data&) { return false; }
virtual bool onEvent(const Events::NGCFT1_send_data&) { return false; } // const? 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<NGCFT1EventI>; using NGCFT1EventProviderI = EventProviderI<NGCFT1EventI>;