2016-07-10 16:33:16 +00:00
|
|
|
#lang syndicate/actor
|
2016-06-27 18:42:42 +00:00
|
|
|
;; Demonstrate sending a message to multiple receivers.
|
|
|
|
|
|
|
|
(struct envelope (destination message) #:prefab)
|
|
|
|
|
2016-07-09 20:18:30 +00:00
|
|
|
(actor (react (on (message (envelope 'alice $message))
|
|
|
|
(log-info "Alice received ~v" message))))
|
2016-06-27 18:42:42 +00:00
|
|
|
|
2016-07-09 20:18:30 +00:00
|
|
|
(actor (react (on (message (envelope 'bob $message))
|
|
|
|
(log-info "Bob received ~v" message))))
|
2016-06-27 18:42:42 +00:00
|
|
|
|
|
|
|
(actor
|
|
|
|
(log-info "Waiting for Alice and Bob.")
|
|
|
|
(until (asserted (observe (envelope 'alice _))))
|
|
|
|
(until (asserted (observe (envelope 'bob _))))
|
|
|
|
|
|
|
|
(log-info "Sending a few messages...")
|
|
|
|
(send! (envelope 'alice "For Alice's eyes only"))
|
|
|
|
(send! (envelope 'bob "Dear Bob, how are you? Kind regards, etc."))
|
|
|
|
(send! (envelope ? "Important announcement!"))
|
|
|
|
|
|
|
|
(log-info "Sent all the messages."))
|