diff options
author | Peter Powell <petpow@saberuk.com> | 2019-07-15 12:43:05 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-07-15 12:55:48 +0100 |
commit | 06e2961a86705d794fd5904000e44a7ae08004d9 (patch) | |
tree | 389d7deffa90b80f5cc468de1b70fda2145877c4 /src/modules/m_spanningtree | |
parent | 0b0443687d072bb1d4a4274828a72bbc9a171ede (diff) |
Split ServerEventListener into {Broadcast,Link,Sync}EventListener.
There is no reason to have these events in one big handler and it
causes unnecessary event hooks to be created by having them like
this.
The ServerEventListener class still exists for compatibility
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 20 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 2 |
5 files changed, 26 insertions, 12 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 1a51955d1..f8531cb01 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -45,7 +45,9 @@ ModuleSpanningTree::ModuleSpanningTree() , map(this) , commands(this) , currmembid(0) - , eventprov(this, "event/server") + , broadcasteventprov(this, "event/server-broadcast") + , linkeventprov(this, "event/server-link") + , synceventprov(this, "event/server-sync") , sslapi(this) , DNS(this, "DNS") , tagevprov(this, "event/messagetag") @@ -687,7 +689,7 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod) { TreeServer* server = i->second; if (!server->IsRoot()) - FOREACH_MOD_CUSTOM(GetEventProvider(), ServerEventListener, OnServerSplit, (server)); + FOREACH_MOD_CUSTOM(GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (server)); } return; } diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 9a9d4733d..1aeffbc72 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -93,9 +93,14 @@ class ModuleSpanningTree */ SpanningTreeProtocolInterface protocolinterface; - /** Event provider for our events - */ - Events::ModuleEventProvider eventprov; + /** Event provider for our broadcast events. */ + Events::ModuleEventProvider broadcasteventprov; + + /** Event provider for our link events. */ + Events::ModuleEventProvider linkeventprov; + + /** Event provider for our sync events. */ + Events::ModuleEventProvider synceventprov; /** API for accessing user SSL certificates. */ UserCertificateAPI sslapi; @@ -158,7 +163,14 @@ class ModuleSpanningTree */ ModResult HandleConnect(const CommandBase::Params& parameters, User* user); - const Events::ModuleEventProvider& GetEventProvider() const { return eventprov; } + /** Retrieves the event provider for broadcast events. */ + const Events::ModuleEventProvider& GetBroadcastEventProvider() const { return broadcasteventprov; } + + /** Retrieves the event provider for link events. */ + const Events::ModuleEventProvider& GetLinkEventProvider() const { return linkeventprov; } + + /** Retrieves the event provider for sync events. */ + const Events::ModuleEventProvider& GetSyncEventProvider() const { return synceventprov; } /** ** *** MODULE EVENTS *** diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index ed15591e9..ca4d1a472 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -123,7 +123,7 @@ void TreeSocket::DoBurst(TreeServer* s) // Send all xlines this->SendXLines(); - FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncNetwork, (bs.server)); + FOREACH_MOD_CUSTOM(Utils->Creator->GetSyncEventProvider(), ServerProtocol::SyncEventListener, OnSyncNetwork, (bs.server)); this->WriteLine(CmdBuilder("ENDBURST")); ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \002"+ s->GetName()+"\002."); @@ -265,7 +265,7 @@ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs) this->WriteLine(CommandMetadata::Builder(chan, item->name, value)); } - FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncChannel, (chan, bs.server)); + FOREACH_MOD_CUSTOM(Utils->Creator->GetSyncEventProvider(), ServerProtocol::SyncEventListener, OnSyncChannel, (chan, bs.server)); } void TreeSocket::SyncChannel(Channel* chan) @@ -301,6 +301,6 @@ void TreeSocket::SendUsers(BurstState& bs) this->WriteLine(CommandMetadata::Builder(user, item->name, value)); } - FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncUser, (user, bs.server)); + FOREACH_MOD_CUSTOM(Utils->Creator->GetSyncEventProvider(), ServerProtocol::SyncEventListener, OnSyncUser, (user, bs.server)); } } diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index bbe66ff83..ec1fb079d 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -117,7 +117,7 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s this->AddHashEntry(); Parent->Children.push_back(this); - FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnServerLink, (this)); + FOREACH_MOD_CUSTOM(Utils->Creator->GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerLink, (this)); } void TreeServer::BeginBurst(uint64_t startms) @@ -207,7 +207,7 @@ void TreeServer::SQuitInternal(unsigned int& num_lost_servers) RemoveHash(); if (!Utils->Creator->dying) - FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnServerSplit, (this)); + FOREACH_MOD_CUSTOM(Utils->Creator->GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (this)); } unsigned int TreeServer::QuitUsers(const std::string& reason) diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index a18ec854d..5fbd16da0 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -171,7 +171,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet for (TreeServer::ChildServers::const_iterator i = children.begin(); i != children.end(); ++i) { ModResult result; - FIRST_MOD_RESULT_CUSTOM(Creator->GetEventProvider(), ServerEventListener, OnBroadcastMessage, result, (c, *i)); + FIRST_MOD_RESULT_CUSTOM(Creator->GetBroadcastEventProvider(), ServerProtocol::BroadcastEventListener, OnBroadcastMessage, result, (c, *i)); if (result == MOD_RES_ALLOW) list.insert((*i)->GetSocket()); } |