warn on setting an event on invalid connection

This commit is contained in:
David Botton 2022-07-06 16:28:29 -04:00
parent ab31788726
commit 075c975b51
2 changed files with 28 additions and 23 deletions

View file

@ -31,8 +31,9 @@ embedded in a native template application.)
STATUS: CLOG 1.4 and CLOG Builder 1.4 released.
CLOG is actually based on GNOGA, a framework I wrote for Ada in 2013
and used in commercial production code for the last 9+ years, i.e. the
techniques CLOG uses are solid and proven.
and used in commercial production code for the last 9+ years. CLOG
itself is already used in commerical products, corporate websites,
and other opensource projects.
CLOG is being actively extended with tools and custom controls daily but the
core API is stable and proven. Check the github discussion boards for the

View file

@ -346,7 +346,9 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(post-eval "")
(cancel-event nil)
(one-time nil))
(let ((hook (format nil "~A:~A" (html-id obj) event)))
(let ((hook (format nil "~A:~A" (html-id obj) event))
(cd (connection-data obj)))
(if cd
(cond (handler
(bind-event-script
obj event (format nil "~Aws.send('E:~A '~A)~A~@[~A~]~@[~A~]"
@ -359,10 +361,11 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(jquery obj)
event))
(when cancel-event "; return false")))
(setf (gethash hook (connection-data obj)) handler))
(setf (gethash hook cd) handler))
(t
(unbind-event-script obj event)
(remhash hook (connection-data obj))))))
(remhash hook cd)))
(format t "Attempt to set event on non-existant connection."))))
;;;;;;;;;;;;;;
;; property ;;
@ -393,7 +396,7 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(:documentation "Get/Setf html height in pixels."))
(defmethod height ((obj clog-obj))
(parse-integer (jquery-query obj "height()") :junk-allowed t))
(parse-integer (jquery-query obj "height()" :default-answer 0) :junk-allowed t))
(defgeneric set-height (clog-obj value)
(:documentation "Set height VALUE for CLOG-OBJ"))
@ -411,7 +414,7 @@ result or if time out DEFAULT-ANSWER. see JQUERY-QUERY (Internal)"))
(:documentation "Get/Setf html width in pixels."))
(defmethod width ((obj clog-obj))
(parse-integer (jquery-query obj "width()") :junk-allowed t))
(parse-integer (jquery-query obj "width()" :default-answer 0) :junk-allowed t))
(defgeneric set-width (clog-obj value)
(:documentation "Set width VALUE for CLOG-OBJ"))
@ -508,7 +511,7 @@ an application share per connection the same queue of serialized events."
(gethash item-name (connection-data obj))))
(defgeneric set-connection-data-item (clog-obj item-name value)
(:documentation "Set connection-data the item-name in hash."))
(:documentation "Set in connection-data the item-name with value."))
(defmethod set-connection-data-item ((obj clog-obj) item-name value)
(bordeaux-threads:with-lock-held ((connection-data-mutex obj))
@ -522,7 +525,8 @@ an application share per connection the same queue of serialized events."
(defmethod remove-connection-data-item ((obj clog-obj) item-name)
(bordeaux-threads:with-lock-held ((connection-data-mutex obj))
(remhash item-name (connection-data obj))))
(ignore-errors
(remhash item-name (connection-data obj)))))
;;;;;;;;;;;;;;;;;;
;; set-on-event ;;