- Timestamp:
- 01/12/07 06:44:39 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp ¶
r31 r33 41 41 ;; response - who 2 'S 42 42 ;; 43 (defclass yarpc-state-machine ( async-fd)())43 (defclass yarpc-state-machine (state-machine)()) 44 44 45 (defun yarpc-state-machine () 46 (make-instance 'yarpc-state-machine)) 47 48 (defparameter yarpc-pf (yarpc-packet-factory)) 49 50 (defmethod get-packet-factory((sm yarpc-state-machine)) 51 yarpc-pf) 45 52 46 53 ;;TODO move somewhere suitable … … 75 82 (format stream "#<YARPC-STATE-MACHINE ~A >" (call-next-method sm nil))) 76 83 77 (defmethod process-read((sm yarpc-state-machine)) 78 (with-slots (foreign-read-buffer foreign-write-buffer) sm 79 (let ((fn-result (execute-call (sb-ext:octets-to-string (get-string foreign-read-buffer) :external-format :ascii)))) 80 (format t "process-read - function result: ~A~%" fn-result) 81 (nio-buffer:bytebuffer-write-string foreign-write-buffer (write-to-string fn-result) 0 :utf-8) 82 (close-sm sm)))) 84 (defconstant STATE-INITIALISED 0) 85 (defconstant STATE-SEND-RESPONSE 1) 83 86 87 (defparameter state STATE-INITIALISED) 84 88 85 89 (define-condition authorization-error (error) ()) 86 90 91 ;Process a call method packet, returns 92 (defmethod process-packet ((sm yarpc-state-machine) (call call-method-packet)) 93 ;todo change state, create method-response packet and return it 94 ;(assert (eql state 0)) 95 (handler-case 96 (let ((result (execute-call (get-call-string call)))) 97 (when result 98 (let ((response-packet (progn 99 (setf state STATE-SEND-RESPONSE) 100 (method-response-packet result)))) 101 (values response-packet t)))) 102 (reader-error (re) (format t "No such function ~A~%" (get-call-string call))) 103 (authorization-error (ae) (format t "Function not declared with defremote ~A~%" (get-call-string call))))) 104 105 87 106 (defun execute-call (call-string) 88 (handler-case89 107 (let* ((rpc-call-list (read-from-string call-string )) 90 108 (fn (member (symbol-function (first rpc-call-list)) *remote-fns* ))) … … 92 110 (if fn 93 111 (apply (first rpc-call-list) (rest rpc-call-list)) 94 (error 'authorization-error))) 95 (reader-error (re) (format t "No such function ~A~%" call-string)))) 112 (error 'authorization-error)))) 96 113
Note: See TracChangeset
for help on using the changeset viewer.