]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/handshaketimer.cpp
Instead of re adding the HandshakeTimer in m_spanningtree, make it a reoccurring...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / handshaketimer.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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 "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "xline.h"
19 #include "transport.h"
20
21 #include "m_spanningtree/main.h"
22 #include "m_spanningtree/utils.h"
23 #include "m_spanningtree/treeserver.h"
24 #include "m_spanningtree/link.h"
25 #include "m_spanningtree/treesocket.h"
26 #include "m_spanningtree/handshaketimer.h"
27
28 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
29
30 HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay) : Timer(delay, Inst->Time(), true), Instance(Inst), sock(s), lnk(l), Utils(u)
31 {
32         thefd = sock->GetFd();
33 }
34
35 void HandshakeTimer::Tick(time_t TIME)
36 {
37         if (Instance->SE->GetRef(thefd) == sock)
38         {
39                 if (!sock->GetHook())
40                 {
41                         CancelRepeat();
42                         sock->SendCapabilities();
43                 }
44                 else
45                 {
46                         if (sock->GetHook() && BufferedSocketHSCompleteRequest(sock, (Module*)Utils->Creator, sock->GetHook()).Send())
47                         {
48                                 CancelRepeat();
49                                 BufferedSocketAttachCertRequest(sock, (Module*)Utils->Creator, sock->GetHook()).Send();
50                                 sock->SendCapabilities();
51                         }
52                         else
53                         {
54                                 // Try again later...
55                         }
56                 }
57         }
58 }
59