summaryrefslogtreecommitdiff
path: root/include/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-07-15 12:43:05 +0100
committerPeter Powell <petpow@saberuk.com>2019-07-15 12:55:48 +0100
commit06e2961a86705d794fd5904000e44a7ae08004d9 (patch)
tree389d7deffa90b80f5cc468de1b70fda2145877c4 /include/modules
parent0b0443687d072bb1d4a4274828a72bbc9a171ede (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 'include/modules')
-rw-r--r--include/modules/server.h49
1 files changed, 46 insertions, 3 deletions
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)
+ {
+ }
+};