4 erc-server-send-ping-interval
#'erc-server-send-ping
buffer))
- (setq erc-server-ping-timer-alist (cons (cons buffer
- erc-server-ping-handler)
- erc-server-ping-timer-alist)))))
+
+ ;; I check the timer alist for an existing timer. If one exists,
+ ;; I get rid of it
+ (let ((timer-tuple (assq buffer erc-server-ping-timer-alist)))
+ (if timer-tuple
+ ;; this buffer already has a timer. Cancel it and set the new one
+ (progn
+ (erc-cancel-timer (cdr timer-tuple))
+ (setf (cdr (assq buffer erc-server-ping-timer-alist)) erc-server-ping-handler))
+
+ ;; no existing timer for this buffer. Add new one
+ (add-to-list 'erc-server-ping-timer-alist
+ (cons buffer erc-server-ping-handler)))))))
(defun erc-server-process-alive (&optional buffer)
"Return non-nil when BUFFER has an `erc-server-process' open or running."
(defun erc-server-connect (server port buffer)
"Perform the connection and login using the specified SERVER and PORT.
We will store server variables in the buffer given by BUFFER."
- (let ((msg (erc-format-message 'connect ?S server ?p port)))
+ (let ((msg (erc-format-message 'connect ?S server ?p port)) process)
(message "%s" msg)
- (let ((process (funcall erc-server-connect-function
- (format "erc-%s-%s" server port)
- nil server port)))
- (unless (processp process)
- (error "Connection attempt failed"))
+ (setq process (funcall erc-server-connect-function
+ (format "erc-%s-%s" server port) nil server port))
+ (unless (processp process)
+ (error "Connection attempt failed"))
+ ;; Misc server variables
+ (with-current-buffer buffer
+ (setq erc-server-process process)
+ (setq erc-server-quitting nil)
+ (setq erc-server-reconnecting nil)
+ (setq erc-server-timed-out nil)
+ (setq erc-server-banned nil)
+ (setq erc-server-error-occurred nil)
+ (let ((time (erc-current-time)))
+ (setq erc-server-last-sent-time time)
+ (setq erc-server-last-ping-time time)
+ (setq erc-server-last-received-time time))
+ (setq erc-server-lines-sent 0)
+ ;; last peers (sender and receiver)
+ (setq erc-server-last-peers '(nil . nil)))
+ ;; we do our own encoding and decoding
+ (when (fboundp 'set-process-coding-system)
+ (set-process-coding-system process 'raw-text))
+ ;; process handlers
+ (set-process-sentinel process 'erc-process-sentinel)
+ (set-process-filter process 'erc-server-filter-function)
+ (set-process-buffer process buffer)
+ (erc-log "\n\n\n********************************************\n")
+ (message "%s" (erc-format-message
+ 'login ?n
+ (with-current-buffer buffer (erc-current-nick))))
+ ;; wait with script loading until we receive a confirmation (first
+ ;; MOTD line)
+ (if (eq (process-status process) 'connect)
+ ;; waiting for a non-blocking connect - keep the user informed
+ (erc-display-message nil nil buffer "Opening connection..\n")
(message "%s...done" msg)
- ;; Misc server variables
- (with-current-buffer buffer
- (setq erc-server-process process)
- (setq erc-server-quitting nil)
- (setq erc-server-reconnecting nil)
- (setq erc-server-timed-out nil)
- (setq erc-server-banned nil)
- (setq erc-server-error-occurred nil)
- (let ((time (erc-current-time)))
- (setq erc-server-last-sent-time time)
- (setq erc-server-last-ping-time time)
- (setq erc-server-last-received-time time))
- (setq erc-server-lines-sent 0)
- ;; last peers (sender and receiver)
- (setq erc-server-last-peers '(nil . nil)))
- ;; we do our own encoding and decoding
- (when (fboundp 'set-process-coding-system)
- (set-process-coding-system process 'raw-text))
- ;; process handlers
- (set-process-sentinel process 'erc-process-sentinel)
- (set-process-filter process 'erc-server-filter-function)
- (set-process-buffer process buffer)))
- (erc-log "\n\n\n********************************************\n")
- (message "%s" (erc-format-message
- 'login ?n
- (with-current-buffer buffer (erc-current-nick))))
- ;; wait with script loading until we receive a confirmation (first
- ;; MOTD line)
- (if (eq erc-server-connect-function 'open-network-stream-nowait)
- ;; it's a bit unclear otherwise that it's attempting to establish a
- ;; connection
- (erc-display-message nil nil buffer "Opening connection..\n")
- (erc-login)))
+ (erc-login)) ))
(defun erc-server-reconnect ()
"Reestablish the current IRC connection.
(setq erc-server-ping-handler nil)))
(run-hook-with-args 'erc-disconnected-hook
(erc-current-nick) (system-name) "")
+ (dolist (buf (erc-buffer-filter (lambda () (boundp 'erc-channel-users)) cproc))
+ (with-current-buffer buf
+ (setq erc-channel-users (make-hash-table :test 'equal))))
;; Remove the prompt
(goto-char (or (marker-position erc-input-marker) (point-max)))
(forward-line 0)
(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 (buffer-live-p buf)
+ (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
(>