]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_rpctest.cpp
Support CAP LS
[user/henk/code/inspircd.git] / src / modules / m_rpctest.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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                 Implementation eventlist[] = { I_OnEvent };
31                 ServerInstance->Modules->Attach(eventlist, this, 1);
32         }
33         
34         virtual ~ModuleRPCTest()
35         {
36         }
37         
38         virtual Version GetVersion()
39         {
40                 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
41         }
42         
43         
44         virtual void OnEvent(Event *ev)
45         {
46                 if (ev->GetEventID() == "RPCMethod")
47                 {
48                         RPCRequest *req = (RPCRequest*) ev->GetData();
49                         
50                         if (req->method == "test.echo")
51                         {
52                                 req->claimed = true;
53                                 if (req->parameters->ArraySize() < 1)
54                                 {
55                                         req->error = "Insufficient parameters";
56                                         return;
57                                 }
58                                 
59                                 req->result->SetString(req->parameters->GetArray(0)->GetString());
60                         }
61                 }
62         }
63 };
64
65 MODULE_INIT(ModuleRPCTest)
66