1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
26 /* $ModDesc: Povides a spanning tree server link protocol */
30 class TreeSocket : public InspSocket
36 TreeSocket(std::string host, int port, bool listening, unsigned long maxtime)
37 : InspSocket(host, port, listening, maxtime)
39 Srv->Log(DEBUG,"Create new");
43 virtual bool OnConnected()
45 Srv->Log(DEBUG,"Connected");
46 Srv->SendToModeMask("o",WM_AND,"*** CONNECTED!");
47 this->Write("GET / HTTP/1.1\r\nHost: " + myhost + "\r\nConnection: Close\r\n\r\n");
48 Srv->SendToModeMask("o",WM_AND,"*** DATA WRITTEN ***");
49 Srv->Log(DEBUG,"Wrote");
53 virtual void OnError(InspSocketError e)
56 Srv->Log(DEBUG,"Error");
57 sprintf(x,"*** ERROR %d",(int)e);
58 Srv->SendToModeMask("o",WM_AND,x);
61 virtual int OnDisconnect()
63 Srv->Log(DEBUG,"Disconnect");
64 Srv->SendToModeMask("o",WM_AND,"*** DISCONNECTED!");
68 virtual bool OnDataReady()
70 Srv->Log(DEBUG,"Data");
71 Srv->SendToModeMask("o",WM_AND,"*** DATA ***");
72 char* data = this->Read();
75 Srv->SendToModeMask("o",WM_AND,data);
77 return (data != NULL);
80 virtual void OnTimeout()
82 Srv->Log(DEBUG,"Timeout");
83 Srv->SendToModeMask("o",WM_AND,"*** TIMED OUT ***");
86 virtual void OnClose()
88 Srv->SendToModeMask("o",WM_AND,"*** CLOSED ***");
91 virtual int OnIncomingConnection()
93 Srv->SendToModeMask("o",WM_AND,"*** INCOMING ***");
98 void handle_connecttest(char **parameters, int pcnt, userrec *user)
100 // create a new class of type TreeSocket.
101 std::string a = parameters[0];
102 TreeSocket* s = new TreeSocket(a,80,false,10);
103 Srv->Log(DEBUG,"Create TreeSocket");
105 Srv->Log(DEBUG,"Added socket");
108 class ModuleSpanningTree : public Module
114 Srv->AddCommand("CONNECTTEST",handle_connecttest,'o',1,"m_spanningtree.so");
115 Srv->Log(DEBUG,"ModCreate");
118 virtual void OnUserJoin(userrec* user, chanrec* channel)
122 virtual ~ModuleSpanningTree()
127 virtual Version GetVersion()
129 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
132 virtual void OnUserConnect(userrec* user)
139 class ModuleSpanningTreeFactory : public ModuleFactory
142 ModuleSpanningTreeFactory()
146 ~ModuleSpanningTreeFactory()
150 virtual Module * CreateModule()
152 return new ModuleSpanningTree;
158 extern "C" void * init_module( void )
160 return new ModuleSpanningTreeFactory;