refactor: Switch TUI/daemon communication from JSON to Lisp S-Expressions
This commit is contained in:
@@ -32,15 +32,20 @@
|
||||
(let ((line (read-line *stream* nil :eof)))
|
||||
(if (eq line :eof)
|
||||
(setf *is-running* nil)
|
||||
(let ((json (ignore-errors (cl-json:decode-json-from-string line))))
|
||||
(if json
|
||||
(let* ((*read-eval* nil)
|
||||
(sexp (ignore-errors (read-from-string line))))
|
||||
(if (and sexp (listp sexp))
|
||||
(cond
|
||||
((string= (cdr (assoc :type json)) "status")
|
||||
((eq (getf sexp :type) :status)
|
||||
(setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]"
|
||||
(cdr (assoc :scribe json))
|
||||
(cdr (assoc :gardener json)))))
|
||||
((string= (cdr (assoc :type json)) "chat")
|
||||
(enqueue-msg (cdr (assoc :text json))))
|
||||
(getf sexp :scribe)
|
||||
(getf sexp :gardener))))
|
||||
((eq (getf sexp :type) :chat)
|
||||
(enqueue-msg (getf sexp :text)))
|
||||
((eq (getf sexp :type) :info)
|
||||
(enqueue-msg (format nil "*System*: ~a" (getf sexp :text))))
|
||||
((eq (getf sexp :type) :error)
|
||||
(enqueue-msg (format nil "*Error*: ~a" (getf sexp :text))))
|
||||
(t (enqueue-msg line)))
|
||||
(enqueue-msg line))))))
|
||||
(error () (setf *is-running* nil)))
|
||||
|
||||
Reference in New Issue
Block a user