diff options
author | Sadie Powell <sadie@witchery.services> | 2025-02-13 01:28:28 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-02-13 01:45:20 +0000 |
commit | f8c1b8f4f9bcb06242aa7d7360ea610764565c75 (patch) | |
tree | 84eed97fb3781ff3b8c0ecbbd8f304cc3e7997ff /include/modules/rpc.h | |
parent | eaa00c7c9e38f7f5633544a767876f2f6d57185d (diff) |
Rework the RPC modules in preparation for the new JSON-RPC module.
Diffstat (limited to 'include/modules/rpc.h')
-rw-r--r-- | include/modules/rpc.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/include/modules/rpc.h b/include/modules/rpc.h new file mode 100644 index 000000000..b3c8afdb4 --- /dev/null +++ b/include/modules/rpc.h @@ -0,0 +1,50 @@ +/* + * + * (C) 2010-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +#include "httpd.h" + +class RPCRequest final +{ + std::map<Anope::string, Anope::string> replies; + +public: + Anope::string name; + Anope::string id; + std::deque<Anope::string> data; + HTTPReply &r; + + RPCRequest(HTTPReply &_r) : r(_r) { } + inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.emplace(dname, ddata); } + inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; } +}; + +class RPCServiceInterface; + +class RPCEvent +{ +public: + virtual ~RPCEvent() = default; + virtual bool Run(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) = 0; +}; + +class RPCServiceInterface + : public Service +{ +public: + RPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, "RPCServiceInterface", sname) { } + + virtual void Register(RPCEvent *event) = 0; + + virtual void Unregister(RPCEvent *event) = 0; + + virtual Anope::string Sanitize(const Anope::string &string) = 0; + + virtual void Reply(RPCRequest &request) = 0; +}; |