Compare commits
No commits in common. "4aab6e489d7203a93c2ae0e269c2ed73da859915" and "fd094b157f754a82424f50b8a2554b2c6213d13e" have entirely different histories.
4aab6e489d
...
fd094b157f
@ -78,7 +78,7 @@ bool NGCEXTEventProvider::parse_ft1_init(
|
||||
e.file_size = 0u;
|
||||
_DATA_HAVE(sizeof(e.file_size), std::cerr << "NGCEXT: packet too small, missing file_size\n"; return false)
|
||||
for (size_t i = 0; i < sizeof(e.file_size); i++, curser++) {
|
||||
e.file_size |= uint64_t(data[curser]) << (i*8);
|
||||
e.file_size |= size_t(data[curser]) << (i*8);
|
||||
}
|
||||
|
||||
// - 1 byte (temporary_file_tf_id)
|
||||
|
@ -30,7 +30,6 @@ namespace Events {
|
||||
uint32_t peer_number;
|
||||
|
||||
// respond to a request with 0 or more message ids, sorted by newest first
|
||||
|
||||
// - peer_key bytes (the msg_ids are from)
|
||||
ToxKey peer_key;
|
||||
|
||||
@ -48,7 +47,6 @@ namespace Events {
|
||||
uint32_t peer_number;
|
||||
|
||||
// request the other side to initiate a FT
|
||||
|
||||
// - 4 byte (file_kind)
|
||||
uint32_t file_kind;
|
||||
|
||||
@ -61,7 +59,6 @@ namespace Events {
|
||||
uint32_t peer_number;
|
||||
|
||||
// tell the other side you want to start a FT
|
||||
|
||||
// - 4 byte (file_kind)
|
||||
uint32_t file_kind;
|
||||
|
||||
@ -91,7 +88,6 @@ namespace Events {
|
||||
uint32_t peer_number;
|
||||
|
||||
// data fragment
|
||||
|
||||
// - 1 byte (temporary_file_tf_id)
|
||||
uint8_t transfer_id;
|
||||
|
||||
|
@ -210,13 +210,13 @@ void NGCFT1::iteratePeer(float time_delta, uint32_t group_number, uint32_t peer_
|
||||
if (transfer.state == Group::Peer::RecvTransfer::State::FINISHING) {
|
||||
transfer.finishing_timer -= time_delta;
|
||||
if (transfer.finishing_timer <= 0.f) {
|
||||
//dispatch(
|
||||
// NGCFT1_Event::recv_done,
|
||||
// Events::NGCFT1_recv_done{
|
||||
// group_number, peer_number,
|
||||
// uint8_t(idx)
|
||||
// }
|
||||
//);
|
||||
dispatch(
|
||||
NGCFT1_Event::recv_done,
|
||||
Events::NGCFT1_recv_done{
|
||||
group_number, peer_number,
|
||||
uint8_t(idx)
|
||||
}
|
||||
);
|
||||
|
||||
peer.recv_transfers.at(idx).reset();
|
||||
}
|
||||
@ -543,7 +543,7 @@ bool NGCFT1::onEvent(const Events::NGCEXT_ft1_init_ack& e) {
|
||||
|
||||
bool NGCFT1::onEvent(const Events::NGCEXT_ft1_data& e) {
|
||||
#if !NDEBUG
|
||||
//std::cout << "NGCFT1: got FT1_DATA " << e.sequence_id << "\n";
|
||||
//std::cout << "NGCFT1: got FT1_DATA\n";
|
||||
#endif
|
||||
|
||||
if (e.data.empty()) {
|
||||
@ -602,14 +602,6 @@ bool NGCFT1::onEvent(const Events::NGCEXT_ft1_data& e) {
|
||||
// TODO: keep around for remote timeout + delay + offset, so we can be sure all acks where received
|
||||
// or implement a dedicated finished that needs to be acked
|
||||
transfer.finishing_timer = 0.5f; // TODO: we are receiving, we dont know delay
|
||||
|
||||
dispatch(
|
||||
NGCFT1_Event::recv_done,
|
||||
Events::NGCFT1_recv_done{
|
||||
e.group_number, e.peer_number,
|
||||
e.transfer_id
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -687,13 +687,14 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_request& e) {
|
||||
// TODO: queue instead
|
||||
//queueUpRequestInfo(e.group_number, e.peer_number, info_hash);
|
||||
uint8_t transfer_id {0};
|
||||
if (_nft.NGC_FT1_send_init_private(
|
||||
_nft.NGC_FT1_send_init_private(
|
||||
e.group_number, e.peer_number,
|
||||
static_cast<uint32_t>(e.file_kind),
|
||||
e.file_id, e.file_id_size,
|
||||
o.get<Components::FT1InfoSHA1Data>().data.size(),
|
||||
&transfer_id
|
||||
)) {
|
||||
);
|
||||
|
||||
_sending_transfers.emplaceInfo(
|
||||
e.group_number, e.peer_number,
|
||||
transfer_id,
|
||||
@ -701,7 +702,6 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_request& e) {
|
||||
o.get<Components::FT1InfoSHA1Data>().data
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number);
|
||||
_tox_peer_to_contact[combine_ids(e.group_number, e.peer_number)] = c; // workaround
|
||||
@ -855,7 +855,6 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_init& e) {
|
||||
|
||||
bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_data& e) {
|
||||
if (!_receiving_transfers.containsPeerTransfer(e.group_number, e.peer_number, e.transfer_id)) {
|
||||
std::cerr << "SHA1_NGCFT1 waring: unknown transfer " << e.transfer_id << " from " << e.group_number << ":" << e.peer_number << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -863,7 +862,6 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_data& e) {
|
||||
|
||||
transfer.time_since_activity = 0.f;
|
||||
if (transfer.isInfo()) {
|
||||
std::cout << "SHA1_NGCFT1: got info data " << e.data_size << "@" << e.data_offset << " from " << e.group_number << ":" << e.peer_number << "\n";
|
||||
auto& info_data = transfer.getInfo().info_data;
|
||||
for (size_t i = 0; i < e.data_size && i + e.data_offset < info_data.size(); i++) {
|
||||
info_data[i+e.data_offset] = e.data[i];
|
||||
@ -877,7 +875,6 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_data& e) {
|
||||
|
||||
auto* file2 = objGetFile2Write(o);
|
||||
if (file2 == nullptr) {
|
||||
std::cerr << "SHA1_NGCFT1 error: writing file failed, no file object\n";
|
||||
return false; // early out
|
||||
}
|
||||
if (!file2->write({e.data, e.data_size}, offset_into_file + e.data_offset)) {
|
||||
|
Loading…
Reference in New Issue
Block a user