]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_rpctest.cpp
Fix for bug #415, affects only trunk (wish i'd known this before i started!)
[user/henk/code/inspircd.git] / src / modules / m_rpctest.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18 #include "rpc.h"
19
20 /* $ModDesc: A test of the RPC API */
21 /* $ModDep: rpc.h */
22
23 class ModuleRPCTest : public Module
24 {
25  private:
26         
27  public:
28         ModuleRPCTest(InspIRCd *Me) : Module(Me)
29         {
30         }
31         
32         virtual ~ModuleRPCTest()
33         {
34         }
35         
36         virtual Version GetVersion()
37         {
38                 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
39         }
40         
41         void Implements(char *List)
42         {
43                 List[I_OnEvent] = 1;
44         }
45         
46         virtual void OnEvent(Event *ev)
47         {
48                 if (ev->GetEventID() == "RPCMethod")
49                 {
50                         RPCRequest *req = (RPCRequest*) ev->GetData();
51                         
52                         if (req->method == "test.echo")
53                         {
54                                 req->claimed = true;
55                                 if (req->parameters->ArraySize() < 1)
56                                 {
57                                         req->error = "Insufficient parameters";
58                                         return;
59                                 }
60                                 
61                                 req->result->SetString(req->parameters->GetArray(0)->GetString());
62                         }
63                 }
64         }
65 };
66
67 MODULE_INIT(ModuleRPCTest);