diff options
-rw-r--r-- | include/modules/spanningtree.h | 29 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 7 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 4 |
4 files changed, 25 insertions, 16 deletions
diff --git a/include/modules/spanningtree.h b/include/modules/spanningtree.h index 99f4f9fc4..0f51c35db 100644 --- a/include/modules/spanningtree.h +++ b/include/modules/spanningtree.h @@ -19,22 +19,23 @@ #pragma once -struct AddServerEvent : public Event -{ - const std::string servername; - AddServerEvent(Module* me, const std::string& name) - : Event(me, "new_server"), servername(name) - { - Send(); - } -}; +#include "event.h" -struct DelServerEvent : public Event +class SpanningTreeEventListener : public Events::ModuleEventListener { - const std::string servername; - DelServerEvent(Module* me, const std::string& name) - : Event(me, "lost_server"), servername(name) + public: + SpanningTreeEventListener(Module* mod) + : ModuleEventListener(mod, "event/spanningtree") { - Send(); } + + /** Fired when a server finishes burst + * @param server Server that recently linked and finished burst + */ + virtual void OnServerLink(const std::string& server) { } + + /** Fired when a server splits + * @param server Server that split + */ + virtual void OnServerSplit(const std::string& server) { } }; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 31d822789..e5e6e522b 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -39,6 +39,7 @@ ModuleSpanningTree::ModuleSpanningTree() : rconnect(this), rsquit(this), map(this) , commands(NULL) , currmembid(0) + , eventprov(this, "event/spanningtree") , DNS(this, "DNS") , loopCall(false) { diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 13c743f73..9fde32cad 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -24,6 +24,7 @@ #pragma once #include "inspircd.h" +#include "event.h" #include "modules/dns.h" #include "servercommand.h" #include "commands.h" @@ -72,6 +73,10 @@ class ModuleSpanningTree : public Module */ SpanningTreeProtocolInterface protocolinterface; + /** Event provider for our events + */ + Events::ModuleEventProvider eventprov; + public: dynamic_reference<DNS::Manager> DNS; @@ -135,6 +140,8 @@ class ModuleSpanningTree : public Module */ static std::string TimeToStr(time_t secs); + const Events::ModuleEventProvider& GetEventProvider() const { return eventprov; } + /** ** *** MODULE EVENTS *** **/ diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index e004f897e..6ebce07f9 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -151,7 +151,7 @@ void TreeServer::FinishBurst() unsigned long bursttime = ts - this->StartBurst; ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)", GetName().c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs")); - AddServerEvent(Utils->Creator, GetName()); + FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), SpanningTreeEventListener, OnServerLink, (GetName())); StartBurst = 0; FinishBurstInternal(); @@ -159,7 +159,7 @@ void TreeServer::FinishBurst() void TreeServer::SQuitChild(TreeServer* server, const std::string& reason) { - DelServerEvent(Utils->Creator, server->GetName()); + FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), SpanningTreeEventListener, OnServerSplit, (server->GetName())); stdalgo::erase(Children, server); if (IsRoot()) |