use sr
This commit is contained in:
parent
c81a04a778
commit
c74c28ab3b
@ -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);
|
||||
}
|
||||
|
||||
void ZoxNGCEventProvider::subscribeToEvents(void) {
|
||||
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PACKET);
|
||||
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET);
|
||||
}
|
||||
|
||||
ZoxNGCEventProvider::ZoxNGCEventProvider(ToxEventProviderI& tep) : _tep(tep) {
|
||||
subscribeToEvents();
|
||||
ZoxNGCEventProvider::ZoxNGCEventProvider(ToxEventProviderI& tep) : _tep_sr(tep.newSubRef(this)) {
|
||||
_tep_sr
|
||||
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PACKET)
|
||||
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET)
|
||||
;
|
||||
}
|
||||
|
||||
bool ZoxNGCEventProvider::onZoxGroupEvent(
|
||||
|
@ -108,11 +108,9 @@ struct ZoxNGCEventI {
|
||||
using ZoxNGCEventProviderI = EventProviderI<ZoxNGCEventI>;
|
||||
|
||||
class ZoxNGCEventProvider : public ToxEventI, public ZoxNGCEventProviderI {
|
||||
ToxEventProviderI& _tep;
|
||||
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||
//ToxI& _t;
|
||||
|
||||
void subscribeToEvents(void); // private
|
||||
|
||||
public:
|
||||
ZoxNGCEventProvider(ToxEventProviderI& tep/*, ToxI& t*/);
|
||||
|
||||
|
@ -14,17 +14,15 @@
|
||||
#include <vector>
|
||||
#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)
|
||||
: _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) {
|
||||
|
@ -15,12 +15,13 @@ struct ToxI;
|
||||
struct ContactModelI;
|
||||
class ToxContactModel2;
|
||||
|
||||
// zoff ngc history sync (draft1?)
|
||||
// https://gist.github.com/zoff99/81917ddb2e55b2ce602cac4772a7b68c
|
||||
// zoff ngc history sync
|
||||
// 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 {
|
||||
ToxEventProviderI& _tep;
|
||||
ZoxNGCEventProviderI& _zngcepi;
|
||||
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||
ZoxNGCEventProviderI::SubscriptionReference _zngcepi_sr;
|
||||
ToxI& _t;
|
||||
Contact3Registry& _cr;
|
||||
ToxContactModel2& _tcm;
|
||||
@ -61,10 +62,6 @@ class ZoxNGCHistorySync : public ToxEventI, public ZoxNGCEventI {
|
||||
};
|
||||
std::map<Contact3, SyncQueueInfo> _sync_queue;
|
||||
|
||||
// sync queue
|
||||
|
||||
void subscribeToEvents(void); // private
|
||||
|
||||
public:
|
||||
ZoxNGCHistorySync(ToxEventProviderI& tep, ZoxNGCEventProviderI& zngcepi, ToxI& t, Contact3Registry& cr, ToxContactModel2& tcm, RegistryMessageModelI& rmm);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user