[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 145/255: periodically ping IGS server to prevent disconnect
From: |
Eric Schulte |
Subject: |
[elpa] 145/255: periodically ping IGS server to prevent disconnect |
Date: |
Sun, 16 Mar 2014 01:02:37 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit b4cb880b189c7c69812b747ba916f8301167675f
Author: Eric Schulte <address@hidden>
Date: Sat Jun 2 21:20:20 2012 -0600
periodically ping IGS server to prevent disconnect
---
back-ends/igs.el | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/back-ends/igs.el b/back-ends/igs.el
index b992936..da4ef47 100644
--- a/back-ends/igs.el
+++ b/back-ends/igs.el
@@ -47,6 +47,9 @@
(defvar igs-process-name "igs"
"Name for the igs process.")
+(defvar igs-server-ping-delay 60
+ "Minimum time between pings to remind the IGS server we're still listening.")
+
(defvar igs-message-types
'((:unknown . 0)
(:automat . 35) ;; Automatch announcement
@@ -91,6 +94,10 @@
(:version . 39) ;; IGS Version
(:yell . 32))) ;; Channel yelling
+(defvar *igs-time-last-sent* nil
+ "Time stamp of the last command sent.
+This is used to re-send messages to keep the IGS server from timing out.")
+
(defvar *igs-ready* nil
"Indicates if the IGS server is waiting for input.")
@@ -105,6 +112,13 @@
`(with-current-buffer (process-buffer proc) ,@body))
(def-edebug-spec igs-w-proc (form body))
+(defun igs-send (command)
+ "Send string COMMAND to the IGS process in the current buffer."
+ (goto-char (process-mark (get-buffer-process (current-buffer))))
+ (insert command)
+ (setq *igs-time-last-sent* (current-time))
+ (comint-send-input))
+
(defun igs-filter-process (proc string)
(when (string-match "^\\([[:digit:]]+\\) \\(.+\\)$" string)
(let* ((number (read (match-string 1 string)))
@@ -116,7 +130,10 @@
(:games (igs-w-proc proc (igs-handle-game content)))
(:move (igs-w-proc proc (igs-handle-move content)))
(:beep nil)
- (t (message "igs-unknown: [%s]%s" type content))))))
+ (t (message "igs-unknown: [%s]%s" type content)))
+ (when (> (time-to-seconds (time-since *igs-time-last-sent*))
+ igs-server-ping-delay)
+ (igs-send "ayt")))))
(defun igs-insertion-filter (proc string)
(with-current-buffer (process-buffer proc)
@@ -145,19 +162,18 @@
(set (make-local-variable '*igs-ready*) nil)
(set (make-local-variable '*igs-games*) nil)
(set (make-local-variable '*igs-current-game*) nil)
+ (set (make-local-variable '*igs-time-last-sent*) (current-time))
(let ((proc (get-buffer-process (current-buffer))))
(wait "^Login:")
(goto-char (process-mark proc))
- (insert igs-username)
- (comint-send-input)
+ (igs-send igs-username)
(wait "^\#> ")
(igs-toggle "client" t)
(set-process-filter proc 'igs-insertion-filter)
buffer)))))
(defun igs-toggle (setting value)
- (insert (format "toggle %s %s" setting (if value "true" "false")))
- (comint-send-input))
+ (igs-send (format "toggle %s %s" setting (if value "true" "false"))))
(defun igs-observe (&optional game)
(interactive)
@@ -165,14 +181,12 @@
"game: "
(mapcar #'number-to-string
(mapcar #'car *igs-games*)))))))
- (insert (format "observe %s" game))
- (comint-send-input)))
+ (igs-send (format "observe %s" game))))
(defun igs-games ()
(interactive)
(setf *igs-games* nil)
- (insert "games")
- (comint-send-input))
+ (igs-send "games"))
(defun igs-game-list (igs)
(let (games)
@@ -293,8 +307,7 @@
(setf (aget (igs-current-game) :board)
(save-excursion (make-instance 'board
:buffer (go-board sgf))))
- (insert (format "moves %s" number))
- (comint-send-input))))
+ (igs-send (format "moves %s" number)))))
(defun igs-update-game-info (info)
(let ((color (car info))
- [elpa] 133/255: igs using a process filter for asynch processing, (continued)
- [elpa] 133/255: igs using a process filter for asynch processing, Eric Schulte, 2014/03/15
- [elpa] 136/255: two small fixes, Eric Schulte, 2014/03/15
- [elpa] 135/255: stubbed out API interface for go-board, Eric Schulte, 2014/03/15
- [elpa] 139/255: fixed off-by-one in igs moves & tracking last move, Eric Schulte, 2014/03/15
- [elpa] 138/255: igs can track a current game and apply moves, Eric Schulte, 2014/03/15
- [elpa] 142/255: TODO igs probably needs to periodically ping the server, Eric Schulte, 2014/03/15
- [elpa] 143/255: pass move through board to *back-end*, Eric Schulte, 2014/03/15
- [elpa] 144/255: tests require igs, Eric Schulte, 2014/03/15
- [elpa] 146/255: print igs kibitz strings, Eric Schulte, 2014/03/15
- [elpa] 141/255: beginning of infrastructure for player names & info, Eric Schulte, 2014/03/15
- [elpa] 145/255: periodically ping IGS server to prevent disconnect,
Eric Schulte <=
- [elpa] 147/255: igs implements the go back-end API, Eric Schulte, 2014/03/15
- [elpa] 148/255: improved the setf method for aget, Eric Schulte, 2014/03/15
- [elpa] 150/255: more lenient regexp for matching game listing, Eric Schulte, 2014/03/15
- [elpa] 152/255: Revert "improved the setf method for aget", Eric Schulte, 2014/03/15
- [elpa] 154/255: don't quit main back-end when quitting a board, Eric Schulte, 2014/03/15
- [elpa] 158/255: beginning to translate svg images into elisp, Eric Schulte, 2014/03/15
- [elpa] 149/255: push all buffer-local variables into an igs object, Eric Schulte, 2014/03/15
- [elpa] 162/255: painting a nice svg board, but more to do, Eric Schulte, 2014/03/15
- [elpa] 159/255: translated all svg stone images into elisp, Eric Schulte, 2014/03/15
- [elpa] 164/255: prompt before quitting, Eric Schulte, 2014/03/15