From 6c782a65689f0b67125a94abfa4520c715f5a4db Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 25 Oct 2024 13:01:16 +0200 Subject: [PATCH] use sr --- src/solanaceae/tox_p2prng/tox_p2prng.cpp | 10 ++++++---- src/solanaceae/tox_p2prng/tox_p2prng.hpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/solanaceae/tox_p2prng/tox_p2prng.cpp b/src/solanaceae/tox_p2prng/tox_p2prng.cpp index b081407..6a87ff3 100644 --- a/src/solanaceae/tox_p2prng/tox_p2prng.cpp +++ b/src/solanaceae/tox_p2prng/tox_p2prng.cpp @@ -259,10 +259,12 @@ ToxP2PRNG::ToxP2PRNG( ToxI& t, ToxEventProviderI& tep, ToxContactModel2& tcm -) : _t(t), _tep(tep), _tcm(tcm) { - _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_LOSSLESS_PACKET); - _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PACKET); - _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET); +) : _t(t), _tep_sr(tep.newSubRef(this)), _tcm(tcm) { + _tep_sr + .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_LOSSLESS_PACKET) + .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PACKET) + .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET) + ; } ToxP2PRNG::~ToxP2PRNG(void) { diff --git a/src/solanaceae/tox_p2prng/tox_p2prng.hpp b/src/solanaceae/tox_p2prng/tox_p2prng.hpp index 5691773..d9ead15 100644 --- a/src/solanaceae/tox_p2prng/tox_p2prng.hpp +++ b/src/solanaceae/tox_p2prng/tox_p2prng.hpp @@ -16,7 +16,7 @@ // TODO: use generic packet handling service (eg ngc_ext) instead class ToxP2PRNG : public P2PRNGI, public ToxEventI { ToxI& _t; - ToxEventProviderI& _tep; + ToxEventProviderI::SubscriptionReference _tep_sr; ToxContactModel2& _tcm; public: