diff options
author | pippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-17 14:50:33 +0000 |
---|---|---|
committer | pippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-07-17 14:50:33 +0000 |
commit | 6f59e7a0a0780da88bad9ba3c28ca32680cfec37 (patch) | |
tree | edc344f7348a58f53d48614646ebe6fa8b66abd6 | |
parent | 801fca4042fa3365f647564e6a060436958aed31 (diff) |
publish "JSON-RPC" interface
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7465 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_rpc_json.cpp | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/modules/m_rpc_json.cpp b/src/modules/m_rpc_json.cpp index 960a06b94..563ca627c 100644 --- a/src/modules/m_rpc_json.cpp +++ b/src/modules/m_rpc_json.cpp @@ -30,32 +30,33 @@ class ModuleRpcJson : public Module { - void MthModuleVersion (HTTPRequest *http, json::Value &request, json::Value &response) - { - std::string result = "GetVersion().ToString()"; - response["result"] = result; - } - - void system_list_methods (HTTPRequest *http, json::Value &request, json::Value &response) - { - unsigned i = 0; - json::Value method_list (json::arrayValue); - - json::rpc::method_map::iterator it; - for (it = json::rpc::methods.begin(); it != json::rpc::methods.end(); ++it) - { - method_list[i] = json::Value (it->first); - i++; - } - - response["result"] = method_list; - } + void MthModuleVersion (HTTPRequest *http, json::Value &request, json::Value &response) + { + std::string result = "GetVersion().ToString()"; + response["result"] = result; + } + + void system_list_methods (HTTPRequest *http, json::Value &request, json::Value &response) + { + unsigned i = 0; + json::Value method_list (json::arrayValue); + + json::rpc::method_map::iterator it; + for (it = json::rpc::methods.begin(); it != json::rpc::methods.end(); ++it) + { + method_list[i] = json::Value (it->first); + i++; + } + + response["result"] = method_list; + } public: ModuleRpcJson(InspIRCd* Me) : Module(Me) { - json::rpc::add_method ("system.listMethods", (Module *)this, (void (Module::*)(HTTPRequest*, json::Value&, json::Value&))&ModuleRpcJson::system_list_methods); - json::rpc::add_method ("ircd.moduleVersion", (Module *)this, (void (Module::*)(HTTPRequest*, json::Value&, json::Value&))&ModuleRpcJson::MthModuleVersion); + ServerInstance->PublishInterface("JSON-RPC", this); + json::rpc::add_method ("system.listMethods", (Module *)this, (void (Module::*)(HTTPRequest*, json::Value&, json::Value&))&ModuleRpcJson::system_list_methods); + json::rpc::add_method ("ircd.moduleVersion", (Module *)this, (void (Module::*)(HTTPRequest*, json::Value&, json::Value&))&ModuleRpcJson::MthModuleVersion); } void OnEvent(Event* event) @@ -95,6 +96,7 @@ class ModuleRpcJson : public Module virtual ~ModuleRpcJson() { + ServerInstance->UnpublishInterface("JSON-RPC", this); } virtual Version GetVersion() @@ -2086,13 +2088,13 @@ namespace json method_map::iterator mthit = methods.find (methodName); if (mthit != methods.end ()) - { - mfp m = mthit->second; - Module *mod = new Module (*m.mod); - method mth = m.mth; - (mod->*mth) (http, request, response); - delete mod; - } + { + mfp m = mthit->second; + Module *mod = new Module (*m.mod); + method mth = m.mth; + (mod->*mth) (http, request, response); + delete mod; + } } void |