From ae10588ada2b32b3c715056b32c042fd221a534d Mon Sep 17 00:00:00 2001 From: Gerd Flaig Date: Sat, 29 Nov 2008 23:35:30 +0100 Subject: [PATCH] Forward prompt to browser --- empire.lisp | 5 +++-- package.lisp | 2 +- static/eow.js | 18 ++++++++++++++---- static/test.html | 6 +++--- web.lisp | 3 +++ 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/empire.lisp b/empire.lisp index 4797ac7..7685f55 100644 --- a/empire.lisp +++ b/empire.lisp @@ -145,9 +145,10 @@ this stream.") (let* ((c (connection m)) (log (logging-stream c))) (with-input-from-string (s message) - (let* ((minutes (read s)) + (let* ((minutes (read s)) ;;FIXME DANGEROUS (btus (read s))) - (format log "[~a:~a]: ~%" minutes btus))))) + (format log "[~a:~a]: ~%" minutes btus) + (empire-web:prompt minutes btus))))) (defparameter *line-type-dispatch* (list `(,+C_DATA+ . handle-data) diff --git a/package.lisp b/package.lisp index 56ca854..26d0ebb 100644 --- a/package.lisp +++ b/package.lisp @@ -16,5 +16,5 @@ (:export :create :enqueue :dequeue)) (defpackage :empire-web (:use :cl :hunchentoot) - (:export :start :send))) + (:export :start :send :prompt))) diff --git a/static/eow.js b/static/eow.js index 00b34ee..55fb20c 100644 --- a/static/eow.js +++ b/static/eow.js @@ -5,14 +5,14 @@ function eowOut(output) { dojo.byId("output").appendChild(p); } -function hello() { +function get_next_update() { dojo.xhrGet( { // The following URL must match that used to test the server. url: "/eow/update", handleAs: "javascript", //handleAs: "text", - timeout: 5000, // Time in milliseconds + timeout: 30000, // Time in milliseconds // The LOAD function will be called on a successful response. load: function(response, ioArgs) { @@ -22,9 +22,19 @@ function hello() { // The ERROR function will be called in an error case. error: function(response, ioArgs) { - console.error("HTTP status code: ", ioArgs.xhr.status); - return response; + if (response.dojoType == "timeout") { + ioArgs.xhr.abort(); + get_next_update(); + return response; + } + + console.error("HTTP status code: ", ioArgs.xhr.status); + return response; } }); } +function prompt(minutes, btus) { + eowOut("[" + minutes + "," + btus + "]: "); + get_next_update(); +} diff --git a/static/test.html b/static/test.html index 3f6cc9f..867d524 100644 --- a/static/test.html +++ b/static/test.html @@ -3,13 +3,13 @@ Empire Web Client - @@ -31,5 +31,5 @@ dojo.addOnLoad(init);
- Last modified: Sun Nov 23 01:38:22 CET 2008 + Last modified: Sat Nov 29 23:06:08 CET 2008 diff --git a/web.lisp b/web.lisp index 0937692..20e2751 100644 --- a/web.lisp +++ b/web.lisp @@ -40,6 +40,9 @@ "Push a javascript update fragment to the client." (locked-queue:enqueue *update-queue* string)) +(defun prompt (minutes btus) + (send (format nil "prompt(~a,~a);~%" minutes btus))) + (defun dispatch (request) (let ((script-name (script-name request))) (cond -- 2.43.0