#lang racket (require goblins goblins/actor-lib/let-on goblins/actor-lib/await goblins/actor-lib/bootstrap goblins/ocapn goblins/ocapn/netlayer/onion syrup "rich-interface-tools.rkt") (define (main parrot-sref describe-sref) (define-vat-run a-run (make-vat)) (define-vat-run machine-run (make-vat)) (define mycapn (machine-run (spawn-mycapn (setup-onion-netlayer)))) (define done (make-semaphore)) (define (uhoh _e) (displayln "Uhoh, something went wrong, huh?") (semaphore-post done)) (a-run (with-await await ;; using await like this avoids the crossed hellos problem ;; while also not solving the crossed hellos problem #thisisfine (define describe (await (<- mycapn 'enliven describe-sref))) (define parrot (await (<- mycapn 'enliven parrot-sref))) (await (on (<- describe parrot) (lambda (iface) (displayln ";; Parrot's interface (encoded):") (display ";") (write iface) (newline) (newline) (displayln ";; Parrot's interface (explained):") (explain-iface iface)) #:catch uhoh #:promise? #t)) (newline) (await (on (<- parrot "Repeat three times" 3) (lambda (parrot-says) (displayln ";; Parrot says:") (display "; ") (display parrot-says) (newline)) #:catch uhoh #:promise? #t)) (semaphore-post done))) ;; hack to wait to close this file until we hear back (let () (sync done) (void))) (module+ main (command-line #:args (parrot-address describe-address) (main (string->ocapn-sturdyref parrot-address) (string->ocapn-sturdyref describe-address))))