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)
32 (require 'riece-server)
34 (defgroup riece-keepalive nil
35 "Keep an IRC connection."
39 (defcustom riece-keepalive-ping-repeat 120
40 "Interval for sending PING to server."
42 :group 'riece-keepalive)
44 (defvar riece-keepalive-timer nil)
46 (defconst riece-keepalive-description
47 "Keep an IRC connection.")
49 (defun riece-keepalive-after-login-hook ()
50 (make-local-variable 'riece-keepalive-timer)
51 (unless riece-keepalive-timer
52 (setq riece-keepalive-timer
54 riece-keepalive-ping-repeat riece-keepalive-ping-repeat
58 (riece-send-string "PING riece-keepalive\r\n")))
61 (defun riece-keepalive-after-close-hook ()
62 (when riece-keepalive-timer
63 (riece-cancel-timer riece-keepalive-timer)
64 (setq riece-keepalive-timer nil)))
66 (defun riece-keepalive-insinuate ()
67 (add-hook 'riece-after-login-hook 'riece-keepalive-after-login-hook)
68 (add-hook 'riece-after-close-hook 'riece-keepalive-after-close-hook))
70 (defun riece-keepalive-uninstall ()
71 (remove-hook 'riece-after-login-hook 'riece-keepalive-after-login-hook)
72 (remove-hook 'riece-after-close-hook 'riece-keepalive-after-close-hook))
74 (provide 'riece-keepalive)
76 ;;; riece-ignore.el ends here