Commit 5929f556 authored by David Byers's avatar David Byers
Browse files

Protocol support for get-stats and get-stats-description.

Detailed changes:
> 	Support get-stats server call:
> 	* utilities.el (lyskom-get-server-stats): New function.
>
> 	* komtypes.el (server-stats): New type.
>
> 	* parse.el (lyskom-parse-float): New function.
> 	(lyskom-parse-stats): New function.
>
> 	* komtypes.el (stats-description): New type.
> 	(stats): New type.
>
> 	* parse.el (lyskom-parse-stats-description): New function.
> 	(lyskom-parse-stats-array): New function.
>
> 	* services.el (initiate-get-stats-description): New function.
>
> 	More work on bug 900 (now nags about presentations):
parent 3d737363
2003-08-03 David Byers <byers@lysator.liu.se>
Support get-stats server call:
* utilities.el (lyskom-get-server-stats): New function.
* komtypes.el (server-stats): New type.
* parse.el (lyskom-parse-float): New function.
(lyskom-parse-stats): New function.
* komtypes.el (stats-description): New type.
(stats): New type.
* parse.el (lyskom-parse-stats-description): New function.
(lyskom-parse-stats-array): New function.
* services.el (initiate-get-stats-description): New function.
More work on bug 900 (now nags about presentations):
* vars.el.in (kom-dont-complain-about-missing-presentation): New
variable.
2003-08-02 David Byers <byers@lysator.liu.se>
* utilities.el (lyskom-nag-about-presentation): New function.
* startup.el (kom-start-anew): Use new function to nag about
......@@ -37,7 +52,7 @@
(lyskom-unread-by-to): Same here.
* commands2.el (kom-status-person): Don't set default when reading
conference name (the default default is better).
conference name (the default default is better).
(kom-send-message): Fall back to the default default when reading
recipient name (better than the empty string, I think).
......
......@@ -823,6 +823,25 @@ Do nothing if the TLIST is less than N elements long."
:nil-safe)
(def-komtype stats-description
((what :read-only t)
(when :read-only t))
:nil-safe)
(def-komtype stats
((average :read-only t)
(ascent-rate :read-only t)
(descent-rate :read-only t))
:nil-safe)
(def-komtype server-stats
(&optional
(what :default nil)
(when :default nil)
(values :default nil))
:nil-safe)
;;; ================================================================
......
......@@ -108,7 +108,7 @@ first non-white character was not equal to CHAR."
(lyskom-string-skip-whitespace
(buffer-substring lyskom-parse-pos (point-max))))
(defun lyskom-parse-num ()
"Parse the next token as a number.
Signal lyskom-parse-incomplete if the number is not followed by whitespace.
......@@ -129,6 +129,23 @@ Signal lyskom-protocol-error if the next token is not a number."
(lyskom-string-to-parse))))
)
(defun lyskom-parse-float ()
"Parse the next token as a float.
Signal lyskom-parse-incomplete if the number is not followed by whitespace.
Signal lyskom-protocol-error if the next token is not a number."
(goto-char lyskom-parse-pos)
(cond ((looking-at "[ \n]*[-+]?[0-9]*\\(\\.[0-9]*\\)?\\([eE][-+]?[0-9]+\\)?")
(if (char-after (match-end 0))
(progn (setq lyskom-parse-pos (goto-char (match-end 0)))
(string-to-number (match-string 0)))
(signal 'lyskom-parse-incomplete nil)))
((looking-at "[ \n]*\\'")
(goto-char (point-max))
(signal 'lyskom-parse-incomplete nil))
(t (lyskom-protocol-error 'lyskom-parse-num
"Expected float, got %S"
(lyskom-string-to-parse)))))
(defun lyskom-parse-string ()
......@@ -1073,6 +1090,24 @@ Args: TEXT-NO. Value: text-stat."
"Parse a Read-Range"
(lyskom-create-text-pair (lyskom-parse-num) (lyskom-parse-num)))
(defun lyskom-parse-stats-description ()
"Parse a Stats-Description"
(lyskom-create-stats-description
(lyskom-parse-vector (lyskom-parse-num) 'lyskom-parse-string)
(lyskom-parse-vector (lyskom-parse-num) 'lyskom-parse-num)))
(defun lyskom-parse-stats ()
"Parse a Stats"
(lyskom-create-stats (lyskom-parse-float)
(lyskom-parse-float)
(lyskom-parse-float)))
(defun lyskom-parse-stats-array ()
"Parse an array of Stats"
(lyskom-parse-vector (lyskom-parse-num) 'lyskom-parse-stats))
;;; ================================================================
;;; Parsing of complex datatypes without cache.
......
......@@ -1303,7 +1303,15 @@ Args: KOM-QUEUE HANDLER SESSION-NO &rest DATA"
(lyskom-call kom-queue lyskom-ref-no handler data 'lyskom-parse-void)
(lyskom-send-packet kom-queue (lyskom-format-objects 109 conf-no text))))
(defun initiate-get-stats-description (kom-queue handler &rest data)
(lyskom-server-call
(lyskom-call kom-queue lyskom-ref-no handler data 'lyskom-parse-stats-description)
(lyskom-send-packet kom-queue (lyskom-format-objects 111))))
(defun initiate-get-stats (kom-queue handler what &rest data)
(lyskom-server-call
(lyskom-call kom-queue lyskom-ref-no handler data 'lyskom-parse-stats-array)
(lyskom-send-packet kom-queue (lyskom-format-objects 112 what))))
;;; ================================================================
......
......@@ -1986,3 +1986,26 @@ Any whitespace and newlines in TEXT will be ignored."
(lyskom-get-server-alias)
72)
(sit-for (if harder 0 1))))))
(defun lyskom-get-server-stats ()
(let ((descr (blocking-do 'get-stats-description)))
(when descr
(let ((result (lyskom-create-server-stats))
(collector (make-collector)))
(set-server-stats->when result
(listify-vector (stats-description->when descr)))
(set-server-stats->what result
(listify-vector (stats-description->what descr)))
(lyskom-traverse name (stats-description->what descr)
(initiate-get-stats 'main
(lambda (res name c)
(when res
(collector-push (cons name (listify-vector res)) c)))
name
name
collector))
(lyskom-wait-queue 'main)
(set-server-stats->values result
(nreverse (collector->value collector)))
result))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment