From 06e2961a86705d794fd5904000e44a7ae08004d9 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 15 Jul 2019 12:43:05 +0100 Subject: 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 --- include/modules/server.h | 49 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'include/modules') diff --git a/include/modules/server.h b/include/modules/server.h index f9907ef26..6bd10b3e3 100644 --- a/include/modules/server.h +++ b/include/modules/server.h @@ -21,11 +21,19 @@ #include "event.h" -class ServerEventListener : public Events::ModuleEventListener +namespace ServerProtocol +{ + class BroadcastEventListener; + class LinkEventListener; + class SyncEventListener; +} + +class ServerProtocol::BroadcastEventListener + : public Events::ModuleEventListener { public: - ServerEventListener(Module* mod) - : ModuleEventListener(mod, "event/server") + BroadcastEventListener(Module* mod) + : ModuleEventListener(mod, "event/server-broadcast") { } @@ -36,6 +44,16 @@ class ServerEventListener : public Events::ModuleEventListener * send the message to the server or MOD_RES_PASSTHRU if no module handled the event. */ virtual ModResult OnBroadcastMessage(Channel* channel, const Server* server) { return MOD_RES_PASSTHRU; } +}; + +class ServerProtocol::LinkEventListener + : public Events::ModuleEventListener +{ + public: + LinkEventListener(Module* mod) + : ModuleEventListener(mod, "event/server-link") + { + } /** Fired when a server finishes burst * @param server Server that recently linked and finished burst @@ -46,6 +64,16 @@ class ServerEventListener : public Events::ModuleEventListener * @param server Server that split */ virtual void OnServerSplit(const Server* server) { } +}; + +class ServerProtocol::SyncEventListener + : public Events::ModuleEventListener +{ + public: + SyncEventListener(Module* mod) + : ModuleEventListener(mod, "event/server-sync") + { + } /** Allows modules to synchronize user metadata during a netburst. This will * be called for every user visible on your side of the burst. @@ -66,3 +94,18 @@ class ServerEventListener : public Events::ModuleEventListener */ virtual void OnSyncNetwork(ProtocolServer& server) { } }; + +/** Compatibility struct for <3.3.0 modules. */ +class ServerEventListener + : public ServerProtocol::BroadcastEventListener + , public ServerProtocol::LinkEventListener + , public ServerProtocol::SyncEventListener +{ + public: + ServerEventListener(Module* mod) + : ServerProtocol::BroadcastEventListener(mod) + , ServerProtocol::LinkEventListener(mod) + , ServerProtocol::SyncEventListener(mod) + { + } +}; -- cgit v1.2.3