Better support for sudden connection lost.

This commit is contained in:
David Botton 2021-11-18 13:58:46 -05:00
parent 844afdf7f4
commit f6792ca0ed
7 changed files with 21 additions and 6 deletions

View file

@ -169,6 +169,7 @@
(sleep .1)))) (sleep .1))))
(defun on-new-window (body) (defun on-new-window (body)
(set-html-on-close body "Connection Lost")
(let ((app (make-instance 'app-data))) (let ((app (make-instance 'app-data)))
(setf (connection-data-item body "app-data") app)) (setf (connection-data-item body "app-data") app))
(display-splash body) (display-splash body)

View file

@ -15,6 +15,7 @@
*global-list-box-hash*)) *global-list-box-hash*))
(defun on-new-window (body) (defun on-new-window (body)
(set-html-on-close body "Connection Lost")
(load-css (html-document body) "/css/w3.css") (load-css (html-document body) "/css/w3.css")
(setf (title (html-document body)) "CLOG Chat") (setf (title (html-document body)) "CLOG Chat")

View file

@ -173,6 +173,7 @@
(declare (ignore obj))())))) (declare (ignore obj))()))))
(defun on-new-window (body) (defun on-new-window (body)
(set-html-on-close body "Connection Lost")
(let ((app (make-instance 'app-data))) (let ((app (make-instance 'app-data)))
(setf (connection-data-item body "app-data") app)) (setf (connection-data-item body "app-data") app))
(clog-gui-initialize body) (clog-gui-initialize body)

View file

@ -159,6 +159,7 @@
(id-me app))))) (id-me app)))))
(defun on-new-window (body) (defun on-new-window (body)
(set-html-on-close body "Connection Lost")
;; Create an app-data object for every connection ;; Create an app-data object for every connection
(let ((app (make-instance 'app-data))) (let ((app (make-instance 'app-data)))
(setf (connection-data-item body "app-data") app) (setf (connection-data-item body "app-data") app)

View file

@ -47,7 +47,7 @@
;;;;;;;;; ;;;;;;;;;
(defgeneric run (clog-body) (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 collection of local objects when not using connection-data objects
or global objects.")) or global objects."))
@ -57,6 +57,15 @@ or global objects."))
(sleep 10) (sleep 10)
(return)))) (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 ;; ;; window ;;
;;;;;;;;;;;; ;;;;;;;;;;;;

View file

@ -492,6 +492,7 @@ HTML <br />."
the browser contents in case of connection loss." the browser contents in case of connection loss."
(execute connection-id (format nil "clog['html_on_close']='~A'" (execute connection-id (format nil "clog['html_on_close']='~A'"
(escape-string html)))) (escape-string html))))
;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;
;; compiled-boot-js ;; ;; compiled-boot-js ;;
;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;

View file

@ -674,6 +674,7 @@ embedded in a native template application.)"
"CLOG-Body - Properties" "CLOG-Body - Properties"
(run generic-function) (run generic-function)
(set-html-on-close generic-function)
(window generic-function) (window generic-function)
(html-document generic-function) (html-document generic-function)
(location generic-function) (location generic-function)