diff --git a/backplane-server.lisp b/backplane-server.lisp index 949e94d..ddc403e 100644 --- a/backplane-server.lisp +++ b/backplane-server.lisp @@ -40,15 +40,20 @@ (defmethod render-result ((res result/success)) (with-slots (message msg-id) res + (cl-json:encode-json + `((STATUS . "OK") + (MESSAGE . ,message) + (MSGID . ,msg-id))) (let ((msg (if message (format nil ":~A" message) "")) (msgid (if msg-id (format nil " (~A)" msg-id) ""))) (format nil "OK~A~A" msgid msg)))) (defmethod render-result ((res result/error)) (with-slots (message msg-id) res - (let ((msg (if message (format nil ":~A" message) "")) - (msgid (if msg-id (format nil " (~A)" msg-id) ""))) - (format nil "ERROR~A~A" msgid msg)))) + (cl-json:encode-json + `((STATUS . "ERROR") + (MESSAGE . ,message) + (MSGID . ,msg-id))))) (defgeneric parse-message (sender service api-version message msg-id) (:documentation "Given an incoming message, turn it into the appropriate request.")) @@ -122,3 +127,10 @@ (format nil "backplane-~A" (machine-instance)) :mechanism :sasl-plain) backplane)))) + + ;;;; nope...capture the var name and make sure it gets closed, but still pass it in +(defmacro with-backplane (backplane &rest ops) + (let ((bp-sym (gensym))) + `(let ((,bp-sym ,backplane)) + (unwind-protect (progn ,@ops) + (cl-xmpp:disconnect ,bp-sym)))))