diff --git a/demos/01-demo.lisp b/demos/01-demo.lisp index 1e1eb49..39e38c5 100644 --- a/demos/01-demo.lisp +++ b/demos/01-demo.lisp @@ -169,6 +169,7 @@ (sleep .1)))) (defun on-new-window (body) + (set-html-on-close body "Connection Lost") (let ((app (make-instance 'app-data))) (setf (connection-data-item body "app-data") app)) (display-splash body) diff --git a/demos/02-demo.lisp b/demos/02-demo.lisp index b950808..5b009b8 100644 --- a/demos/02-demo.lisp +++ b/demos/02-demo.lisp @@ -15,6 +15,7 @@ *global-list-box-hash*)) (defun on-new-window (body) + (set-html-on-close body "Connection Lost") (load-css (html-document body) "/css/w3.css") (setf (title (html-document body)) "CLOG Chat") diff --git a/demos/03-demo.lisp b/demos/03-demo.lisp index 0654781..3acfe7c 100644 --- a/demos/03-demo.lisp +++ b/demos/03-demo.lisp @@ -173,6 +173,7 @@ (declare (ignore obj))())))) (defun on-new-window (body) + (set-html-on-close body "Connection Lost") (let ((app (make-instance 'app-data))) (setf (connection-data-item body "app-data") app)) (clog-gui-initialize body) diff --git a/demos/04-demo.lisp b/demos/04-demo.lisp index 3d6de47..5e732e5 100644 --- a/demos/04-demo.lisp +++ b/demos/04-demo.lisp @@ -159,6 +159,7 @@ (id-me app))))) (defun on-new-window (body) + (set-html-on-close body "Connection Lost") ;; Create an app-data object for every connection (let ((app (make-instance 'app-data))) (setf (connection-data-item body "app-data") app) diff --git a/source/clog-body.lisp b/source/clog-body.lisp index 3f04399..c1d7ed2 100644 --- a/source/clog-body.lisp +++ b/source/clog-body.lisp @@ -47,7 +47,7 @@ ;;;;;;;;; (defgeneric run (clog-body) - (:documentation "Keeps the main thread alive to prevent garbage + (:documentation "Keeps the connection thread alive to prevent garbage collection of local objects when not using connection-data objects or global objects.")) @@ -57,6 +57,15 @@ or global objects.")) (sleep 10) (return)))) +;;;;;;;;;;;;;;;;;;;;;;; +;; set-html-on-close ;; +;;;;;;;;;;;;;;;;;;;;;;; + +(defun set-html-on-close (clog-body html) + "In case of connection loss to this CLOG-BODY, replace the browser contents +with HTML." + (clog-connection:set-html-on-close (connection-id clog-body) html)) + ;;;;;;;;;;;; ;; window ;; ;;;;;;;;;;;; diff --git a/source/clog-connection.lisp b/source/clog-connection.lisp index fde4f55..7a78164 100644 --- a/source/clog-connection.lisp +++ b/source/clog-connection.lisp @@ -492,6 +492,7 @@ HTML
." the browser contents in case of connection loss." (execute connection-id (format nil "clog['html_on_close']='~A'" (escape-string html)))) + ;;;;;;;;;;;;;;;;;;;;;; ;; compiled-boot-js ;; ;;;;;;;;;;;;;;;;;;;;;; diff --git a/source/clog.lisp b/source/clog.lisp index f4851f6..af7174f 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -673,11 +673,12 @@ embedded in a native template application.)" (clog-body class) "CLOG-Body - Properties" - (run generic-function) - (window generic-function) - (html-document generic-function) - (location generic-function) - (navigator generic-function)) + (run generic-function) + (set-html-on-close generic-function) + (window generic-function) + (html-document generic-function) + (location generic-function) + (navigator generic-function)) (defsection @clog-window (:title "CLOG Window Objects") "CLOG-Window - CLOG Window Objects"