(defun handle-emacs-client (stream) ;; Logic for parsing length-prefixed OACP messages (format nil "Handling client on stream: ~a" stream)) (defun stream-to-emacs (stream action-plist) "Streams a chunk of data to a specific Emacs client over OACP using framing." (let* ((msg (prin1-to-string action-plist)) (len (length msg)) (framed (format nil "~6,'0x~a" len msg))) (write-string framed stream) (finish-output stream))) (defun broadcast-to-emacs (action-plist context) "Sends a framed message back to the client that sent the stimulus." (let ((stream (getf context :reply-stream))) (if stream (handler-case (stream-to-emacs stream action-plist) (error (c) (kernel-log "BRIDGE ERROR: Failed to write to Emacs: ~a" c))) (kernel-log "BRIDGE ERROR: No reply-stream in context."))))