diff --git a/literate/tui-client.org b/literate/tui-client.org index 6a9d248..258e602 100644 --- a/literate/tui-client.org +++ b/literate/tui-client.org @@ -53,20 +53,19 @@ The OpenCortex TUI Client is a standalone Common Lisp application built on **Cro (when (and *stream* (open-stream-p *stream*)) (let ((raw-msg (opencortex:read-framed-message *stream*))) (unless (member raw-msg '(:eof :error)) - (let ((msg (clean-keywords raw-msg))) - (let* ((msg (clean-keywords raw-msg)) - (type (or (getf msg :TYPE) (getf msg :type)))) - (cond ((eq type :EVENT) - (let ((payload (or (getf msg :PAYLOAD) (getf msg :payload)))) - (when (eq (or (getf payload :ACTION) (getf payload :action)) :handshake) - (setf *status-text* "Ready")))) - ((eq type :STATUS) - (setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]" - (or (getf msg :SCRIBE) (getf msg :scribe)) - (or (getf msg :GARDENER) (getf msg :gardener))))) - ((eq type :CHAT) - (enqueue-msg (or (getf msg :TEXT) (getf msg :text)))) - (t (enqueue-msg (format nil "~s" msg)))))))) + (let* ((msg (clean-keywords raw-msg)) + (type (or (getf msg :TYPE) (getf msg :type)))) + (cond ((eq type :EVENT) + (let ((payload (or (getf msg :PAYLOAD) (getf msg :payload)))) + (when (eq (or (getf payload :ACTION) (getf payload :action)) :handshake) + (setf *status-text* "Ready")))) + ((eq type :STATUS) + (setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]" + (or (getf msg :SCRIBE) (getf msg :scribe)) + (or (getf msg :GARDENER) (getf msg :gardener))))) + ((eq type :CHAT) + (enqueue-msg (or (getf msg :TEXT) (getf msg :text)))) + (t (enqueue-msg (format nil "~s" msg)))))) (when (eq raw-msg :eof) (setf *is-running* nil)) (when (eq raw-msg :error) (setf *status-text* "Protocol Error")))) (error (c) (setf *status-text* (format nil "Net Error: ~a" c)) (setf *is-running* nil))) diff --git a/src/tui-client.lisp b/src/tui-client.lisp index 0b9c2f1..9105b9f 100644 --- a/src/tui-client.lisp +++ b/src/tui-client.lisp @@ -40,20 +40,19 @@ (when (and *stream* (open-stream-p *stream*)) (let ((raw-msg (opencortex:read-framed-message *stream*))) (unless (member raw-msg '(:eof :error)) - (let ((msg (clean-keywords raw-msg))) - (let* ((msg (clean-keywords raw-msg)) - (type (or (getf msg :TYPE) (getf msg :type)))) - (cond ((eq type :EVENT) - (let ((payload (or (getf msg :PAYLOAD) (getf msg :payload)))) - (when (eq (or (getf payload :ACTION) (getf payload :action)) :handshake) - (setf *status-text* "Ready")))) - ((eq type :STATUS) - (setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]" - (or (getf msg :SCRIBE) (getf msg :scribe)) - (or (getf msg :GARDENER) (getf msg :gardener))))) - ((eq type :CHAT) - (enqueue-msg (or (getf msg :TEXT) (getf msg :text)))) - (t (enqueue-msg (format nil "~s" msg)))))))) + (let* ((msg (clean-keywords raw-msg)) + (type (or (getf msg :TYPE) (getf msg :type)))) + (cond ((eq type :EVENT) + (let ((payload (or (getf msg :PAYLOAD) (getf msg :payload)))) + (when (eq (or (getf payload :ACTION) (getf payload :action)) :handshake) + (setf *status-text* "Ready")))) + ((eq type :STATUS) + (setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]" + (or (getf msg :SCRIBE) (getf msg :scribe)) + (or (getf msg :GARDENER) (getf msg :gardener))))) + ((eq type :CHAT) + (enqueue-msg (or (getf msg :TEXT) (getf msg :text)))) + (t (enqueue-msg (format nil "~s" msg)))))) (when (eq raw-msg :eof) (setf *is-running* nil)) (when (eq raw-msg :error) (setf *status-text* "Protocol Error")))) (error (c) (setf *status-text* (format nil "Net Error: ~a" c)) (setf *is-running* nil)))