1 ;;; riece-keepalive.el --- keep an IRC connection
2 ;; Copyright (C) 1998-2004 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: IRC, riece
8 ;; This file is part of Riece.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; NOTE: This is an add-on module for Riece.
31 (require 'riece-options)
33 (defgroup riece-keepalive nil
34 "Keep an IRC connection."
38 (defcustom riece-keepalive-ping-repeat 120
39 "Interval for sending PING to server."
41 :group 'riece-keepalive)
43 (defvar riece-keepalive-timer nil)
45 (defconst riece-keepalive-description
46 "Keep an IRC connection.")
48 (defun riece-keepalive-after-login-hook ()
49 (make-local-variable 'riece-keepalive-timer)
50 (unless riece-keepalive-timer
51 (setq riece-keepalive-timer
53 riece-keepalive-ping-repeat riece-keepalive-ping-repeat
57 (riece-send-string "PING riece-keepalive\r\n")))
60 (defun riece-keepalive-after-close-hook ()
61 (when riece-keepalive-timer
62 (riece-cancel-timer riece-keepalive-timer)
63 (setq riece-keepalive-timer nil)))
65 (defun riece-keepalive-insinuate ()
66 (add-hook 'riece-after-login-hook #'riece-keepalive-after-login-hook)
67 (add-hook 'riece-after-close-hook #'riece-keepalive-after-close-hook))
69 (provide 'riece-keepalive)
71 ;;; riece-ignore.el ends here