This commit is contained in:
Green Sky 2024-10-25 12:18:17 +02:00
parent c81a04a778
commit c74c28ab3b
No known key found for this signature in database
4 changed files with 18 additions and 27 deletions

View File

@ -38,13 +38,11 @@ std::optional<std::pair<uint8_t, uint8_t>> parse_zox_pkg_header(const uint8_t* d
return std::make_pair(version, pkt_id); return std::make_pair(version, pkt_id);
} }
void ZoxNGCEventProvider::subscribeToEvents(void) { ZoxNGCEventProvider::ZoxNGCEventProvider(ToxEventProviderI& tep) : _tep_sr(tep.newSubRef(this)) {
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PACKET); _tep_sr
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PACKET)
} .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET)
;
ZoxNGCEventProvider::ZoxNGCEventProvider(ToxEventProviderI& tep) : _tep(tep) {
subscribeToEvents();
} }
bool ZoxNGCEventProvider::onZoxGroupEvent( bool ZoxNGCEventProvider::onZoxGroupEvent(

View File

@ -108,11 +108,9 @@ struct ZoxNGCEventI {
using ZoxNGCEventProviderI = EventProviderI<ZoxNGCEventI>; using ZoxNGCEventProviderI = EventProviderI<ZoxNGCEventI>;
class ZoxNGCEventProvider : public ToxEventI, public ZoxNGCEventProviderI { class ZoxNGCEventProvider : public ToxEventI, public ZoxNGCEventProviderI {
ToxEventProviderI& _tep; ToxEventProviderI::SubscriptionReference _tep_sr;
//ToxI& _t; //ToxI& _t;
void subscribeToEvents(void); // private
public: public:
ZoxNGCEventProvider(ToxEventProviderI& tep/*, ToxI& t*/); ZoxNGCEventProvider(ToxEventProviderI& tep/*, ToxI& t*/);

View File

@ -14,17 +14,15 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
void ZoxNGCHistorySync::subscribeToEvents(void) {
_zngcepi.subscribe(this, ZoxNGC_Event::ngch_request);
_zngcepi.subscribe(this, ZoxNGC_Event::ngch_syncmsg);
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN);
}
ZoxNGCHistorySync::ZoxNGCHistorySync(ToxEventProviderI& tep, ZoxNGCEventProviderI& zngcepi, ToxI& t, Contact3Registry& cr, ToxContactModel2& tcm, RegistryMessageModelI& rmm) ZoxNGCHistorySync::ZoxNGCHistorySync(ToxEventProviderI& tep, ZoxNGCEventProviderI& zngcepi, ToxI& t, Contact3Registry& cr, ToxContactModel2& tcm, RegistryMessageModelI& rmm)
: _tep(tep), _zngcepi(zngcepi), _t(t), _cr(cr), _tcm(tcm), _rmm(rmm), _rng(std::random_device{}()) : _tep_sr(tep.newSubRef(this)), _zngcepi_sr(zngcepi.newSubRef(this)), _t(t), _cr(cr), _tcm(tcm), _rmm(rmm), _rng(std::random_device{}())
{ {
subscribeToEvents(); _tep_sr.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN);
_zngcepi_sr
.subscribe(ZoxNGC_Event::ngch_request)
.subscribe(ZoxNGC_Event::ngch_syncmsg)
;
} }
float ZoxNGCHistorySync::tick(float delta) { float ZoxNGCHistorySync::tick(float delta) {

View File

@ -15,12 +15,13 @@ struct ToxI;
struct ContactModelI; struct ContactModelI;
class ToxContactModel2; class ToxContactModel2;
// zoff ngc history sync (draft1?) // zoff ngc history sync
// https://gist.github.com/zoff99/81917ddb2e55b2ce602cac4772a7b68c // https://github.com/zoff99/c-toxcore/blob/zoff99/zoxcore_local_fork/docs/ngc_group_history_sync.md
// (old) https://gist.github.com/zoff99/81917ddb2e55b2ce602cac4772a7b68c
class ZoxNGCHistorySync : public ToxEventI, public ZoxNGCEventI { class ZoxNGCHistorySync : public ToxEventI, public ZoxNGCEventI {
ToxEventProviderI& _tep; ToxEventProviderI::SubscriptionReference _tep_sr;
ZoxNGCEventProviderI& _zngcepi; ZoxNGCEventProviderI::SubscriptionReference _zngcepi_sr;
ToxI& _t; ToxI& _t;
Contact3Registry& _cr; Contact3Registry& _cr;
ToxContactModel2& _tcm; ToxContactModel2& _tcm;
@ -61,10 +62,6 @@ class ZoxNGCHistorySync : public ToxEventI, public ZoxNGCEventI {
}; };
std::map<Contact3, SyncQueueInfo> _sync_queue; std::map<Contact3, SyncQueueInfo> _sync_queue;
// sync queue
void subscribeToEvents(void); // private
public: public:
ZoxNGCHistorySync(ToxEventProviderI& tep, ZoxNGCEventProviderI& zngcepi, ToxI& t, Contact3Registry& cr, ToxContactModel2& tcm, RegistryMessageModelI& rmm); ZoxNGCHistorySync(ToxEventProviderI& tep, ZoxNGCEventProviderI& zngcepi, ToxI& t, Contact3Registry& cr, ToxContactModel2& tcm, RegistryMessageModelI& rmm);