From e4eaf91a68e9be5089794ec46ebc6007d9fb697a Mon Sep 17 00:00:00 2001 From: Green Sky Date: Thu, 24 Oct 2024 14:56:26 +0200 Subject: [PATCH] use sr --- .../ircclient_contact_model.cpp | 20 ++++++++++--------- .../ircclient_contact_model.hpp | 1 + .../ircclient_message_manager.cpp | 16 ++++++++------- .../ircclient_message_manager.hpp | 2 ++ 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/solanaceae/ircclient_contacts/ircclient_contact_model.cpp b/src/solanaceae/ircclient_contacts/ircclient_contact_model.cpp index ae01ab4..ef58c34 100644 --- a/src/solanaceae/ircclient_contacts/ircclient_contact_model.cpp +++ b/src/solanaceae/ircclient_contacts/ircclient_contact_model.cpp @@ -19,19 +19,21 @@ IRCClientContactModel::IRCClientContactModel( Contact3Registry& cr, ConfigModelI& conf, IRCClient1& ircc -) : _cr(cr), _conf(conf), _ircc(ircc) { - _ircc.subscribe(this, IRCClient_Event::CONNECT); +) : _cr(cr), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)) { + _ircc_sr + .subscribe(IRCClient_Event::CONNECT) - _ircc.subscribe(this, IRCClient_Event::NUMERIC); + .subscribe(IRCClient_Event::NUMERIC) - _ircc.subscribe(this, IRCClient_Event::JOIN); - _ircc.subscribe(this, IRCClient_Event::PART); - _ircc.subscribe(this, IRCClient_Event::TOPIC); - _ircc.subscribe(this, IRCClient_Event::QUIT); + .subscribe(IRCClient_Event::JOIN) + .subscribe(IRCClient_Event::PART) + .subscribe(IRCClient_Event::TOPIC) + .subscribe(IRCClient_Event::QUIT) - _ircc.subscribe(this, IRCClient_Event::CTCP_REQ); + .subscribe(IRCClient_Event::CTCP_REQ) - _ircc.subscribe(this, IRCClient_Event::DISCONNECT); + .subscribe(IRCClient_Event::DISCONNECT) + ; // dont create server self etc until connect event comes diff --git a/src/solanaceae/ircclient_contacts/ircclient_contact_model.hpp b/src/solanaceae/ircclient_contacts/ircclient_contact_model.hpp index a7836ed..fb1f158 100644 --- a/src/solanaceae/ircclient_contacts/ircclient_contact_model.hpp +++ b/src/solanaceae/ircclient_contacts/ircclient_contact_model.hpp @@ -16,6 +16,7 @@ class IRCClientContactModel : public IRCClientEventI, public ContactModel3I { Contact3Registry& _cr; ConfigModelI& _conf; IRCClient1& _ircc; + IRCClient1::SubscriptionReference _ircc_sr; // cm needs the connect event to happen bool _connected {false}; diff --git a/src/solanaceae/ircclient_messages/ircclient_message_manager.cpp b/src/solanaceae/ircclient_messages/ircclient_message_manager.cpp index 2985220..4a2b26e 100644 --- a/src/solanaceae/ircclient_messages/ircclient_message_manager.cpp +++ b/src/solanaceae/ircclient_messages/ircclient_message_manager.cpp @@ -22,14 +22,16 @@ IRCClientMessageManager::IRCClientMessageManager( ConfigModelI& conf, IRCClient1& ircc, IRCClientContactModel& ircccm -) : _rmm(rmm), _cr(cr), _conf(conf), _ircc(ircc), _ircccm(ircccm) { - _ircc.subscribe(this, IRCClient_Event::CHANNEL); - _ircc.subscribe(this, IRCClient_Event::PRIVMSG); - _ircc.subscribe(this, IRCClient_Event::NOTICE); - _ircc.subscribe(this, IRCClient_Event::CHANNELNOTICE); - _ircc.subscribe(this, IRCClient_Event::CTCP_ACTION); +) : _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _cr(cr), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)), _ircccm(ircccm) { + _ircc_sr + .subscribe(IRCClient_Event::CHANNEL) + .subscribe(IRCClient_Event::PRIVMSG) + .subscribe(IRCClient_Event::NOTICE) + .subscribe(IRCClient_Event::CHANNELNOTICE) + .subscribe(IRCClient_Event::CTCP_ACTION) + ; - _rmm.subscribe(this, RegistryMessageModel_Event::send_text); + _rmm_sr.subscribe(RegistryMessageModel_Event::send_text); } IRCClientMessageManager::~IRCClientMessageManager(void) { diff --git a/src/solanaceae/ircclient_messages/ircclient_message_manager.hpp b/src/solanaceae/ircclient_messages/ircclient_message_manager.hpp index 34d9d5c..d47932e 100644 --- a/src/solanaceae/ircclient_messages/ircclient_message_manager.hpp +++ b/src/solanaceae/ircclient_messages/ircclient_message_manager.hpp @@ -7,9 +7,11 @@ class IRCClientMessageManager : public IRCClientEventI, public RegistryMessageModelEventI { protected: RegistryMessageModelI& _rmm; + RegistryMessageModelI::SubscriptionReference _rmm_sr; Contact3Registry& _cr; ConfigModelI& _conf; IRCClient1& _ircc; + IRCClient1::SubscriptionReference _ircc_sr; IRCClientContactModel& _ircccm; public: