use sr
This commit is contained in:
parent
51396314d1
commit
c7485c4577
@ -3,9 +3,11 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
NGCEXTEventProvider::NGCEXTEventProvider(ToxI& t, ToxEventProviderI& tep) : _t(t), _tep(tep) {
|
NGCEXTEventProvider::NGCEXTEventProvider(ToxI& t, ToxEventProviderI& tep) : _t(t), _tep(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)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _DATA_HAVE(x, error) if ((data_size - curser) < (x)) { error; }
|
#define _DATA_HAVE(x, error) if ((data_size - curser) < (x)) { error; }
|
||||||
|
@ -314,6 +314,7 @@ using NGCEXTEventProviderI = EventProviderI<NGCEXTEventI>;
|
|||||||
class NGCEXTEventProvider : public ToxEventI, public NGCEXTEventProviderI {
|
class NGCEXTEventProvider : public ToxEventI, public NGCEXTEventProviderI {
|
||||||
ToxI& _t;
|
ToxI& _t;
|
||||||
ToxEventProviderI& _tep;
|
ToxEventProviderI& _tep;
|
||||||
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NGCEXTEventProvider(ToxI& t, ToxEventProviderI& tep);
|
NGCEXTEventProvider(ToxI& t, ToxEventProviderI& tep);
|
||||||
|
@ -251,16 +251,18 @@ NGCFT1::NGCFT1(
|
|||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep,
|
ToxEventProviderI& tep,
|
||||||
NGCEXTEventProvider& neep
|
NGCEXTEventProvider& neep
|
||||||
) : _t(t), _tep(tep), _neep(neep)
|
) : _t(t), _tep(tep), _tep_sr(_tep.newSubRef(this)), _neep(neep), _neep_sr(_neep.newSubRef(this))
|
||||||
{
|
{
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_REQUEST);
|
_neep_sr
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_INIT);
|
.subscribe(NGCEXT_Event::FT1_REQUEST)
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_INIT_ACK);
|
.subscribe(NGCEXT_Event::FT1_INIT)
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_DATA);
|
.subscribe(NGCEXT_Event::FT1_INIT_ACK)
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_DATA_ACK);
|
.subscribe(NGCEXT_Event::FT1_DATA)
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_MESSAGE);
|
.subscribe(NGCEXT_Event::FT1_DATA_ACK)
|
||||||
|
.subscribe(NGCEXT_Event::FT1_MESSAGE)
|
||||||
|
;
|
||||||
|
|
||||||
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT);
|
_tep_sr.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
float NGCFT1::iterate(float time_delta) {
|
float NGCFT1::iterate(float time_delta) {
|
||||||
|
@ -132,7 +132,9 @@ using NGCFT1EventProviderI = EventProviderI<NGCFT1EventI>;
|
|||||||
class NGCFT1 : public ToxEventI, public NGCEXTEventI, public NGCFT1EventProviderI {
|
class NGCFT1 : public ToxEventI, public NGCEXTEventI, public NGCFT1EventProviderI {
|
||||||
ToxI& _t;
|
ToxI& _t;
|
||||||
ToxEventProviderI& _tep;
|
ToxEventProviderI& _tep;
|
||||||
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||||
NGCEXTEventProvider& _neep; // not the interface?
|
NGCEXTEventProvider& _neep; // not the interface?
|
||||||
|
NGCEXTEventProvider::SubscriptionReference _neep_sr;
|
||||||
|
|
||||||
std::default_random_engine _rng{std::random_device{}()};
|
std::default_random_engine _rng{std::random_device{}()};
|
||||||
|
|
||||||
|
@ -201,36 +201,49 @@ SHA1_NGCFT1::SHA1_NGCFT1(
|
|||||||
NGCEXTEventProvider& neep
|
NGCEXTEventProvider& neep
|
||||||
) :
|
) :
|
||||||
_os(os),
|
_os(os),
|
||||||
|
_os_sr(_os.newSubRef(this)),
|
||||||
_cr(cr),
|
_cr(cr),
|
||||||
_rmm(rmm),
|
_rmm(rmm),
|
||||||
|
_rmm_sr(_rmm.newSubRef(this)),
|
||||||
_nft(nft),
|
_nft(nft),
|
||||||
|
_nft_sr(_nft.newSubRef(this)),
|
||||||
_tcm(tcm),
|
_tcm(tcm),
|
||||||
_tep(tep),
|
_tep(tep),
|
||||||
|
_tep_sr(_tep.newSubRef(this)),
|
||||||
_neep(neep),
|
_neep(neep),
|
||||||
|
_neep_sr(_neep.newSubRef(this)),
|
||||||
_mfb(os)
|
_mfb(os)
|
||||||
{
|
{
|
||||||
|
_os_sr
|
||||||
// TODO: also create and destroy
|
// TODO: also create and destroy
|
||||||
//_os.subscribe(this, ObjectStore_Event::object_construct);
|
// .subscribe(ObjectStore_Event::object_construct)
|
||||||
_os.subscribe(this, ObjectStore_Event::object_update);
|
.subscribe(ObjectStore_Event::object_update)
|
||||||
//_os.subscribe(this, ObjectStore_Event::object_destroy);
|
// .subscribe(ObjectStore_Event::object_destroy)
|
||||||
|
;
|
||||||
|
|
||||||
_nft.subscribe(this, NGCFT1_Event::recv_request);
|
_nft_sr
|
||||||
_nft.subscribe(this, NGCFT1_Event::recv_init);
|
.subscribe(NGCFT1_Event::recv_request)
|
||||||
_nft.subscribe(this, NGCFT1_Event::recv_data);
|
.subscribe(NGCFT1_Event::recv_init)
|
||||||
_nft.subscribe(this, NGCFT1_Event::send_data);
|
.subscribe(NGCFT1_Event::recv_data)
|
||||||
_nft.subscribe(this, NGCFT1_Event::recv_done);
|
.subscribe(NGCFT1_Event::send_data)
|
||||||
_nft.subscribe(this, NGCFT1_Event::send_done);
|
.subscribe(NGCFT1_Event::recv_done)
|
||||||
_nft.subscribe(this, NGCFT1_Event::recv_message);
|
.subscribe(NGCFT1_Event::send_done)
|
||||||
|
.subscribe(NGCFT1_Event::recv_message)
|
||||||
|
;
|
||||||
|
|
||||||
_rmm.subscribe(this, RegistryMessageModel_Event::send_file_path);
|
_rmm_sr.subscribe(RegistryMessageModel_Event::send_file_path);
|
||||||
|
|
||||||
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN);
|
_tep_sr
|
||||||
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT);
|
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN)
|
||||||
|
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT)
|
||||||
|
;
|
||||||
|
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_HAVE);
|
_neep_sr
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_BITSET);
|
.subscribe(NGCEXT_Event::FT1_HAVE)
|
||||||
_neep.subscribe(this, NGCEXT_Event::FT1_HAVE_ALL);
|
.subscribe(NGCEXT_Event::FT1_BITSET)
|
||||||
_neep.subscribe(this, NGCEXT_Event::PC1_ANNOUNCE);
|
.subscribe(NGCEXT_Event::FT1_HAVE_ALL)
|
||||||
|
.subscribe(NGCEXT_Event::PC1_ANNOUNCE)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHA1_NGCFT1::iterate(float delta) {
|
float SHA1_NGCFT1::iterate(float delta) {
|
||||||
|
@ -22,13 +22,18 @@
|
|||||||
|
|
||||||
class SHA1_NGCFT1 : public ToxEventI, public RegistryMessageModelEventI, public ObjectStoreEventI, public NGCFT1EventI, public NGCEXTEventI {
|
class SHA1_NGCFT1 : public ToxEventI, public RegistryMessageModelEventI, public ObjectStoreEventI, public NGCFT1EventI, public NGCEXTEventI {
|
||||||
ObjectStore2& _os;
|
ObjectStore2& _os;
|
||||||
|
ObjectStore2::SubscriptionReference _os_sr;
|
||||||
// TODO: backend abstraction
|
// TODO: backend abstraction
|
||||||
Contact3Registry& _cr;
|
Contact3Registry& _cr;
|
||||||
RegistryMessageModelI& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
|
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
||||||
NGCFT1& _nft;
|
NGCFT1& _nft;
|
||||||
|
NGCFT1::SubscriptionReference _nft_sr;
|
||||||
ToxContactModel2& _tcm;
|
ToxContactModel2& _tcm;
|
||||||
ToxEventProviderI& _tep;
|
ToxEventProviderI& _tep;
|
||||||
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||||
NGCEXTEventProvider& _neep;
|
NGCEXTEventProvider& _neep;
|
||||||
|
NGCEXTEventProvider::SubscriptionReference _neep_sr;
|
||||||
|
|
||||||
Backends::SHA1MappedFilesystem _mfb;
|
Backends::SHA1MappedFilesystem _mfb;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user