mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
Extensible handle-message
This commit is contained in:
parent
961b87f285
commit
3b27576174
1 changed files with 9 additions and 0 deletions
|
|
@ -89,11 +89,20 @@
|
|||
;; handle-message ;;
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defvar *message-handlers* '()
|
||||
"List of message handling functions.
|
||||
Each entry in the list should be a FUNCTION-DESIGNATOR that will receive
|
||||
a splitted message and a connection id and should return something
|
||||
other than NIL iff it handled the message.")
|
||||
|
||||
(defun handle-message (connection message)
|
||||
"Handle incoming websocket MESSAGE on CONNECTION. (Private)"
|
||||
(handler-case
|
||||
(let ((connection-id (gethash connection *connections*))
|
||||
(ml (ppcre:split ":" message :limit 2)))
|
||||
(dolist (message-handler *message-handlers*)
|
||||
(when (funcall message-handler ml connection-id)
|
||||
(return-from handle-message)))
|
||||
(cond ((null connection-id)
|
||||
;; a zombie connection
|
||||
(when *verbose-output*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue