2018-07-31 18:46:36 +00:00
|
|
|
#lang typed/syndicate/roles
|
|
|
|
|
|
|
|
;; Expected Output
|
|
|
|
;; pong: 8339
|
|
|
|
|
|
|
|
(define-type-alias ds-type
|
2018-09-12 21:03:19 +00:00
|
|
|
(U (Message (Tuple String Int))
|
2018-07-31 18:46:36 +00:00
|
|
|
(Observe (Tuple String ★/t))))
|
|
|
|
|
2019-01-25 15:51:46 +00:00
|
|
|
(run-ground-dataspace ds-type
|
2018-07-31 18:46:36 +00:00
|
|
|
(spawn ds-type
|
|
|
|
(start-facet echo
|
2018-09-12 21:03:19 +00:00
|
|
|
(on (message (tuple "ping" (bind x Int)))
|
|
|
|
(send! (tuple "pong" x)))))
|
2018-07-31 18:46:36 +00:00
|
|
|
(spawn ds-type
|
|
|
|
(start-facet serve
|
2018-09-12 21:03:19 +00:00
|
|
|
(on start
|
|
|
|
(send! (tuple "ping" 8339)))
|
|
|
|
(on (message (tuple "pong" (bind x Int)))
|
2019-01-25 15:51:46 +00:00
|
|
|
(printf "pong: ~v\n" x)))))
|