1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 20:53:13 +02:00

Switch RPC event registration to use the service system.

This commit is contained in:
Sadie Powell
2025-03-17 12:58:22 +00:00
parent 85fbc500d8
commit bb1f93f150
7 changed files with 67 additions and 169 deletions
+5 -14
View File
@@ -21,9 +21,6 @@ namespace RPC
class ServiceInterface;
class Value;
/** Represents a list of registered events. */
using Events = Anope::map<Event *>;
/** Represents possible types of RPC value. */
using ValueUnion = std::variant<Array, Map, Anope::string, std::nullptr_t, bool, double, int64_t, uint64_t>;
@@ -171,15 +168,17 @@ public:
inline const auto &GetRoot() const { return this->root; }
};
#define RPC_EVENT "RPC::Event"
class RPC::Event
: public Service
{
private:
Anope::string event;
size_t minparams;
protected:
Event(const Anope::string& e, size_t mp = 0)
: event(e)
Event(Module *o, const Anope::string& e, size_t mp = 0)
: Service(o, RPC_EVENT, e)
, minparams(mp)
{
}
@@ -187,8 +186,6 @@ protected:
public:
virtual ~Event() = default;
const auto &GetEvent() const { return event; }
const auto &GetMinParams() const { return minparams; }
virtual bool Run(ServiceInterface *iface, HTTPClient *client, Request &request) = 0;
@@ -203,12 +200,6 @@ public:
{
}
virtual const Events &GetEvents() = 0;
virtual bool Register(Event *event) = 0;
virtual bool Unregister(Event *event) = 0;
virtual void Reply(Request &request) = 0;
};