Changeset 3923003
- Timestamp:
- 2010-03-28T02:49:19Z (15 years ago)
- Branches:
- master
- Children:
- 38ee021
- Parents:
- 6761a40
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
r6761a40 r3923003 28 28 GSList *irc_connection_list; 29 29 30 static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond ); 30 31 static char *set_eval_charset( set_t *set, char *value ); 31 32 … … 87 88 myhost = g_strdup( "localhost.localdomain" ); 88 89 89 //if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 )90 //irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc );90 if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 ) 91 irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc ); 91 92 92 93 irc_connection_list = g_slist_append( irc_connection_list, irc ); … … 689 690 690 691 692 /* Returns 0 if everything seems to be okay, a number >0 when there was a 693 timeout. The number returned is the number of seconds we received no 694 pongs from the user. When not connected yet, we don't ping but drop the 695 connection when the user fails to connect in IRC_LOGIN_TIMEOUT secs. */ 696 static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond ) 697 { 698 irc_t *irc = _irc; 699 int rv = 0; 700 701 if( !( irc->status & USTATUS_LOGGED_IN ) ) 702 { 703 if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) ) 704 rv = gettime() - irc->last_pong; 705 } 706 else 707 { 708 if( ( gettime() > ( irc->last_pong + global.conf->ping_interval ) ) && !irc->pinging ) 709 { 710 irc_write( irc, "PING :%s", IRC_PING_STRING ); 711 irc->pinging = 1; 712 } 713 else if( gettime() > ( irc->last_pong + global.conf->ping_timeout ) ) 714 { 715 rv = gettime() - irc->last_pong; 716 } 717 } 718 719 if( rv > 0 ) 720 { 721 irc_abort( irc, 0, "Ping Timeout: %d seconds", rv ); 722 return FALSE; 723 } 724 725 return TRUE; 726 } 727 691 728 692 729 static char *set_eval_charset( set_t *set, char *value ) -
irc_commands.c
r6761a40 r3923003 106 106 irc_write( irc, ":%s PONG %s :%s", irc->root->host, 107 107 irc->root->host, cmd[1]?cmd[1]:irc->root->host ); 108 } 109 110 static void irc_cmd_pong( irc_t *irc, char **cmd ) 111 { 112 /* We could check the value we get back from the user, but in 113 fact we don't care, we're just happy s/he's still alive. */ 114 irc->last_pong = gettime(); 115 irc->pinging = 0; 108 116 } 109 117 … … 517 525 } 518 526 519 static void irc_cmd_pong( irc_t *irc, char **cmd )520 {521 /* We could check the value we get back from the user, but in522 fact we don't care, we're just happy he's still alive. */523 irc->last_pong = gettime();524 irc->pinging = 0;525 }526 527 527 static void irc_cmd_version( irc_t *irc, char **cmd ) 528 528 { … … 568 568 { "quit", 0, irc_cmd_quit, 0 }, 569 569 { "ping", 0, irc_cmd_ping, 0 }, 570 { "pong", 0, irc_cmd_pong, IRC_CMD_LOGGED_IN }, 570 571 { "join", 1, irc_cmd_join, IRC_CMD_LOGGED_IN }, 571 572 { "names", 1, irc_cmd_names, IRC_CMD_LOGGED_IN }, … … 588 589 { "nickserv", 1, irc_cmd_nickserv, IRC_CMD_LOGGED_IN }, 589 590 { "ns", 1, irc_cmd_nickserv, IRC_CMD_LOGGED_IN }, 590 { "pong", 0, irc_cmd_pong, IRC_CMD_LOGGED_IN },591 591 { "version", 0, irc_cmd_version, IRC_CMD_LOGGED_IN }, 592 592 { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
Note: See TracChangeset
for help on using the changeset viewer.