solanaceae_ngc_ft1/solanaceae/ngc_hs2/ngc_hs2_recv.cpp

114 lines
2.4 KiB
C++
Raw Normal View History

#include "./ngc_hs2_recv.hpp"
2024-10-30 17:12:05 +01:00
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
NGCHS2Recv::NGCHS2Recv(
2024-11-01 11:31:05 +01:00
Contact3Registry& cr,
RegistryMessageModelI& rmm,
2024-10-30 17:12:05 +01:00
ToxContactModel2& tcm,
ToxEventProviderI& tep,
NGCFT1& nft
) :
2024-11-01 11:31:05 +01:00
_cr(cr),
_rmm(rmm),
_rmm_sr(_rmm.newSubRef(this)),
2024-10-30 17:12:05 +01:00
_tcm(tcm),
_tep_sr(tep.newSubRef(this)),
_nft(nft),
_nftep_sr(_nft.newSubRef(this))
{
2024-11-01 11:31:05 +01:00
_rmm_sr
.subscribe(RegistryMessageModel_Event::message_construct)
.subscribe(RegistryMessageModel_Event::message_updated)
.subscribe(RegistryMessageModel_Event::message_destroy)
;
2024-10-30 17:12:05 +01:00
_tep_sr
.subscribe(TOX_EVENT_GROUP_PEER_JOIN)
.subscribe(TOX_EVENT_GROUP_PEER_EXIT)
;
_nftep_sr
.subscribe(NGCFT1_Event::recv_request)
.subscribe(NGCFT1_Event::recv_init)
.subscribe(NGCFT1_Event::recv_data)
.subscribe(NGCFT1_Event::send_data)
.subscribe(NGCFT1_Event::recv_done)
.subscribe(NGCFT1_Event::send_done)
;
}
NGCHS2Recv::~NGCHS2Recv(void) {
2024-10-30 17:12:05 +01:00
}
float NGCHS2Recv::iterate(float delta) {
2024-10-30 17:12:05 +01:00
return 1000.f;
}
bool NGCHS2Recv::onEvent(const Message::Events::MessageConstruct&) {
2024-11-01 11:31:05 +01:00
return false;
}
bool NGCHS2Recv::onEvent(const Message::Events::MessageUpdated&) {
2024-11-01 11:31:05 +01:00
return false;
}
bool NGCHS2Recv::onEvent(const Message::Events::MessageDestory&) {
2024-11-01 11:31:05 +01:00
return false;
}
bool NGCHS2Recv::onEvent(const Events::NGCFT1_recv_request& e) {
2024-10-30 17:12:05 +01:00
if (
e.file_kind != NGCFT1_file_kind::HS2_INFO_RANGE_TIME &&
e.file_kind != NGCFT1_file_kind::HS2_SINGLE_MESSAGE
) {
return false; // not for us
}
return false;
}
bool NGCHS2Recv::onEvent(const Events::NGCFT1_recv_init& e) {
2024-10-30 17:12:05 +01:00
if (
e.file_kind != NGCFT1_file_kind::HS2_INFO_RANGE_TIME &&
e.file_kind != NGCFT1_file_kind::HS2_SINGLE_MESSAGE
) {
return false; // not for us
}
return false;
}
bool NGCHS2Recv::onEvent(const Events::NGCFT1_recv_data&) {
2024-10-30 17:12:05 +01:00
return false;
}
bool NGCHS2Recv::onEvent(const Events::NGCFT1_send_data&) {
2024-10-30 17:12:05 +01:00
return false;
}
bool NGCHS2Recv::onEvent(const Events::NGCFT1_recv_done&) {
2024-10-30 17:12:05 +01:00
return false;
}
bool NGCHS2Recv::onEvent(const Events::NGCFT1_send_done&) {
2024-10-30 17:12:05 +01:00
return false;
}
bool NGCHS2Recv::onToxEvent(const Tox_Event_Group_Peer_Join* e) {
2024-10-30 17:12:05 +01:00
const auto group_number = tox_event_group_peer_join_get_group_number(e);
const auto peer_number = tox_event_group_peer_join_get_peer_id(e);
const auto c = _tcm.getContactGroupPeer(group_number, peer_number);
assert(c);
// add to check list with inital cooldown
return false;
}
bool NGCHS2Recv::onToxEvent(const Tox_Event_Group_Peer_Exit* e) {
2024-10-30 17:12:05 +01:00
return false;
}