Skip to content

Commit

Permalink
use sr
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Oct 25, 2024
1 parent 050c7f3 commit 117e40d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/factorio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ void Factorio::sendToLinked(const std::string& message) {
Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageModelI& rmm, FactorioLogParser& flp) :
_cr(cr),
_rmm(rmm),
_flp(flp)
_rmm_sr(_rmm.newSubRef(this)),
_flp(flp),
_flp_sr(_flp.newSubRef(this))
{
// config
for (const auto&& [contact_id, enabled] : conf.entries_bool("Factorio", "link_to_contact")) {
Expand All @@ -46,16 +48,18 @@ Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageMode
_linked_contacts.push_back(h);
}

_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);

_flp.subscribe(this, FactorioLogParser_Event::join);
_flp.subscribe(this, FactorioLogParser_Event::leave);
_flp.subscribe(this, FactorioLogParser_Event::chat);
_flp.subscribe(this, FactorioLogParser_Event::died);
_flp.subscribe(this, FactorioLogParser_Event::evolution);
_flp.subscribe(this, FactorioLogParser_Event::research_started);
_flp.subscribe(this, FactorioLogParser_Event::research_finished);
_flp.subscribe(this, FactorioLogParser_Event::research_cancelled);
_rmm_sr.subscribe(RegistryMessageModel_Event::message_construct);

_flp_sr
.subscribe(FactorioLogParser_Event::join)
.subscribe(FactorioLogParser_Event::leave)
.subscribe(FactorioLogParser_Event::chat)
.subscribe(FactorioLogParser_Event::died)
.subscribe(FactorioLogParser_Event::evolution)
.subscribe(FactorioLogParser_Event::research_started)
.subscribe(FactorioLogParser_Event::research_finished)
.subscribe(FactorioLogParser_Event::research_cancelled)
;
}

Factorio::~Factorio(void) {
Expand Down
2 changes: 2 additions & 0 deletions src/factorio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ struct ConfigModelI;
class Factorio : public RegistryMessageModelEventI, public FactorioLogParserEventI {
Contact3Registry& _cr;
RegistryMessageModelI& _rmm;
RegistryMessageModelI::SubscriptionReference _rmm_sr;
FactorioLogParser& _flp;
FactorioLogParser::SubscriptionReference _flp_sr;

std::vector<Contact3Handle> _linked_contacts;

Expand Down

0 comments on commit 117e40d

Please sign in to comment.