Function: erc-server-send-ping

erc-server-send-ping is a byte-compiled function defined in erc-backend.el.gz.

Signature

(erc-server-send-ping BUF)

Documentation

Send a ping to the IRC server buffer in BUF.

Additionally, detect whether the IRC process has hung.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-backend.el.gz
(defun erc-server-send-ping (buf)
  "Send a ping to the IRC server buffer in BUF.
Additionally, detect whether the IRC process has hung."
  (if (and (buffer-live-p buf)
           (with-current-buffer buf
             erc-server-last-received-time))
      (with-current-buffer buf
        (if (and erc-server-send-ping-timeout
                 (time-less-p
                  erc-server-send-ping-timeout
                  (time-since erc-server-last-received-time)))
            (progn
              ;; if the process is hung, kill it
              (setq erc-server-timed-out t)
              (delete-process erc-server-process))
          (erc-server-send (format "PING %.0f" (erc-current-time)))))
    ;; remove timer if the server buffer has been killed
    (let ((timer (assq buf erc-server-ping-timer-alist)))
      (when timer
        (cancel-timer (cdr timer))
        (setcdr timer nil)))))