diff options
author | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-09-13 14:55:21 +0000 |
---|---|---|
committer | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-09-13 14:55:21 +0000 |
commit | f8f8c81e6fd8993a9de830af0be1709955c28a5f (patch) | |
tree | 896738495896a5e9cc31ebda20224555eac451ac /src/modules/m_rpctest.cpp | |
parent | 15f624f682e73d61bf46ef60fe4f4d7a9dda3e8e (diff) |
Redesigned m_rpc_json to work properly in a modular environment, and added the beginnings of a framework-inspecific RPC interface for modules. Be warned, this WILL change some - this can be considered an alpha :P
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8033 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_rpctest.cpp')
-rw-r--r-- | src/modules/m_rpctest.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/modules/m_rpctest.cpp b/src/modules/m_rpctest.cpp new file mode 100644 index 000000000..faa0f9279 --- /dev/null +++ b/src/modules/m_rpctest.cpp @@ -0,0 +1,68 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" +#include "users.h" +#include "channels.h" +#include "modules.h" +#include "rpc.h" + +/* $ModDesc: A test of the RPC API */ +/* $ModDep: rpc.h */ + +class ModuleRPCTest : public Module +{ + private: + + public: + ModuleRPCTest(InspIRCd *Me) + : Module::Module(Me) + { + } + + virtual ~ModuleRPCTest() + { + } + + virtual Version GetVersion() + { + return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION); + } + + void Implements(char *List) + { + List[I_OnEvent] = 1; + } + + virtual void OnEvent(Event *ev) + { + if (ev->GetEventID() == "RPCMethod") + { + RPCRequest *req = (RPCRequest*) ev->GetData(); + + if (req->method == "test.echo") + { + req->claimed = true; + if (req->parameters->ArraySize() < 1) + { + req->error = "Insufficient parameters"; + return; + } + + req->result->SetString(req->parameters->GetArray(0)->GetString()); + } + } + } +}; + +MODULE_INIT(ModuleRPCTest); |