Пример определения протокола с помощью предметно-ориентированного языка Etiquette.
(defprotocol frp () (while-phase proceed (proceed-p :from :initiator) ; iteration over frp-body (:sub frp-body) ; until client decides to terminate (:sub bye))) (defprotocol frp-body (frp) (case-phase request (command-sel :from :initiator :converter 'to-line) (GET (:sub frp-get)) ; GET file (PUT (:sub frp-put)) ; PUT file (CD (:sub frp-cd)) ; CD directory (BYE (:sub bye)))) ; BYE Goodbye (defprotocol frp-get (frp) (phase query (:from :initiator :converter 'to-line) ; gets the line from parent (GET query)) ; GET is command, query is action (if-phase granted (granted-p :from :respondent) (:sub frp-get-transfer) ACCESS-DENIED)) (defprotocol frp-get-transfer () (phase size (:from :initiator :converter 'to-object) ; SIZE bytecount (SIZE transfer-size)) ; server passes the size at once (if-phase confirm (confirm-p :from :respondent) ; wait for confirmation from client CONFIRM TERMINATE) (phase data (:from :initiator) (DATA transfer-data))) ; server is sending data (defprotocol frp-put () (phase query (:from :initiator :converter 'to-line) ; gets the line from parent (PUT query)) ; PUT is command, query is action (if-phase granted (granted-p :from :respondent) (:sub frp-put-transfer) ACCESS-DENIED)) (defprotocol frp-put-transfer () ;;; Server is initiator and has confirmed receiving (phase confirm (:from :initiator) ; pass the confirmation CONFIRM) (phase size (:from :respondent :converter 'to-object) ; SIZE bytecount (SIZE transfer-size)) ; client passes the size (phase data (:from :respondent) ; DATA (DATA transfer-data))) ; client is sending data (defprotocol frp-cd () (phase query (:from :initiator :converter 'to-line) ; gets the line from parent (CD query)) ; CD is command, query is action (if-phase granted (granted-p :from :respondent) CONFIRM ACCESS-DENIED)) (defprotocol bye () (phase bye (:from :initiator :to :respondent) BYE) (finish))