2016-04-01 23:53:46 +00:00
|
|
|
#lang syndicate
|
2016-01-14 20:19:00 +00:00
|
|
|
|
2016-04-01 23:53:46 +00:00
|
|
|
(require syndicate/actor)
|
2016-01-14 20:19:00 +00:00
|
|
|
|
|
|
|
(struct echo-req (body) #:prefab)
|
|
|
|
(struct echo-resp (body) #:prefab)
|
|
|
|
|
2016-07-09 20:18:30 +00:00
|
|
|
(actor (react (field [count 0])
|
|
|
|
(on (message (echo-req $body))
|
|
|
|
(send! (echo-resp body))
|
|
|
|
(count (+ (count) 1)))))
|
2016-01-14 20:19:00 +00:00
|
|
|
|
2016-07-09 20:18:30 +00:00
|
|
|
(actor (react (on (message (echo-resp $body))
|
|
|
|
(printf "Received: ~v\n" body))))
|
2016-01-14 20:19:00 +00:00
|
|
|
|
2016-02-05 23:03:40 +00:00
|
|
|
(actor (until (asserted (observe (echo-req _))))
|
|
|
|
(until (asserted (observe (echo-resp _))))
|
|
|
|
(send! (echo-req 0))
|
|
|
|
(send! (echo-req 1))
|
|
|
|
(send! (echo-req 2)))
|