ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/packet.C
(Generate patch)

Comparing ermyth/src/packet.C (file contents):
Revision 1.3 by pippijn, Sat Jul 21 13:23:22 2007 UTC vs.
Revision 1.4 by pippijn, Tue Aug 28 17:08:12 2007 UTC

1/* 1/*
2 * packet.C: IRC packet handling. 2 * packet.C: IRC packet handling.
3 * Rights to this code are documented in doc/pod/license.pod. 3 * Rights to this code are documented in doc/pod/license.pod.
4 * 4 *
5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) 5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 */ 6 */
7 7
8static char const rcsid[] = "$Id: packet.C,v 1.3 2007/07/21 13:23:22 pippijn Exp $"; 8static char const rcsid[] = "$Id: packet.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $";
9 9
10#include "atheme.h" 10#include "atheme.h"
11#include "uplink.h" 11#include "uplink.h"
12#include "datastream.h" 12#include "datastream.h"
13
14static void on_connected (connection_t *cptr);
13 15
14/* bursting timer */ 16/* bursting timer */
15#if HAVE_GETTIMEOFDAY 17#if HAVE_GETTIMEOFDAY
16struct timeval burstime; 18struct timeval burstime;
17#endif 19#endif
45{ 47{
46 unsigned int diff; 48 unsigned int diff;
47 49
48 if (me.connected) 50 if (me.connected)
49 { 51 {
50 ping_sts (); 52 phandler->ping_sts ();
51 53
52 diff = NOW - me.uplinkpong; 54 diff = NOW - me.uplinkpong;
53 55
54 if (diff >= 600) 56 if (diff >= 600)
55 { 57 {
67 if (!me.connected) 69 if (!me.connected)
68 event_delete (ping_uplink, NULL); 70 event_delete (ping_uplink, NULL);
69} 71}
70 72
71static void 73static void
72irc_handle_connect (void *vptr) 74on_connected (connection_t *cptr)
73{ 75{
74 connection_t *cptr = static_cast<connection_t *> (vptr);
75
76 /* add our server */ 76 /* add our server */
77 77
78 if (cptr == curr_uplink->conn) 78 if (cptr == curr_uplink->conn)
79 { 79 {
80 cptr->flags = CF_UPLINK; 80 cptr->flags = CF_UPLINK;
83 /* no SERVER message received */ 83 /* no SERVER message received */
84 me.recvsvr = false; 84 me.recvsvr = false;
85 85
86 slog (LG_INFO, "irc_handle_connect(): connection to uplink established"); 86 slog (LG_INFO, "irc_handle_connect(): connection to uplink established");
87 87
88 server_login (); 88 phandler->server_login ();
89 89
90#ifdef HAVE_GETTIMEOFDAY 90#ifdef HAVE_GETTIMEOFDAY
91 /* start our burst timer */ 91 /* start our burst timer */
92 s_time (&burstime); 92 s_time (&burstime);
93#endif 93#endif
94 94
95 /* done bursting by this time... */ 95 /* done bursting by this time... */
96 ping_sts (); 96 phandler->ping_sts ();
97 97
98 /* ping our uplink every 5 minutes */ 98 /* ping our uplink every 5 minutes */
99 event_delete (ping_uplink, NULL); 99 event_delete (ping_uplink, NULL);
100 event_add ("ping_uplink", ping_uplink, NULL, 300); 100 event_add ("ping_uplink", ping_uplink, NULL, 300);
101 me.uplinkpong = time (NULL); 101 me.uplinkpong = NOW;
102 } 102 }
103} 103}
104 104
105void 105void
106init_ircpacket (void) 106init_ircpacket (void)
107{ 107{
108 hook_add_event ("connected"); 108 connection_t::callback.connected.attach (on_connected);
109 hook_add_hook ("connected", irc_handle_connect);
110} 109}
111
112/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
113 * vim:ts=8
114 * vim:sw=8
115 * vim:noexpandtab
116 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines